Skip to content

Commit

Permalink
Updated contract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Feb 28, 2016
1 parent a7d4c7b commit 1c4e21d
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 49 deletions.
7 changes: 1 addition & 6 deletions src/Contracts/ColumnFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

use Illuminate\Database\Eloquent\Builder;

interface ColumnFilterInterface
interface ColumnFilterInterface extends Initializable
{
/**
* Initialize column filter.
*/
public function initialize();

/**
* @param RepositoryInterface $repository
* @param NamedColumnInterface $column
Expand Down
7 changes: 1 addition & 6 deletions src/Contracts/ColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

use Illuminate\Database\Eloquent\Model;

interface ColumnInterface
interface ColumnInterface extends Initializable
{
/**
* Initialize column.
*/
public function initialize();

/**
* @param Model $model
*
Expand Down
8 changes: 2 additions & 6 deletions src/Contracts/DisplayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
namespace SleepingOwl\Admin\Contracts;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;

interface DisplayInterface extends Arrayable
interface DisplayInterface extends Arrayable, Renderable, Initializable
{
/**
* Initialize display.
*/
public function initialize();

/**
* Set display class.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Builder;

interface FilterInterface
interface FilterInterface extends Initializable
{
/**
* Initialize filter.
Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/FormButtonsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace SleepingOwl\Admin\Contracts;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use SleepingOwl\Admin\Model\ModelConfiguration;

interface FormButtonsInterface
interface FormButtonsInterface extends Renderable, Arrayable
{
/**
* @param ModelConfiguration $modelConfiguration
Expand Down
9 changes: 3 additions & 6 deletions src/Contracts/FormElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
namespace SleepingOwl\Admin\Contracts;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;

interface FormElementInterface
interface FormElementInterface extends Renderable, Arrayable, Initializable
{
/**
* Initialize form item.
*/
public function initialize();

/**
* Set currently rendered instance.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Contracts/Initializable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace SleepingOwl\Admin\Contracts;

use Illuminate\Contracts\Validation\Validator;
use SleepingOwl\Admin\Model\ModelConfiguration;

interface Initializable
{
/**
* Initialize class
*/
public function initialize();
}
3 changes: 2 additions & 1 deletion src/Display/DisplayDatatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SleepingOwl\Admin\Display;

use SleepingOwl\Admin\Contracts\Initializable;
use SleepingOwl\Admin\Contracts\ColumnFilterInterface;

class DisplayDatatables extends DisplayTable
Expand Down Expand Up @@ -43,7 +44,7 @@ public function initialize()
{
parent::initialize();
foreach ($this->getColumnFilters() as $columnFilter) {
if ($columnFilter instanceof ColumnFilterInterface) {
if ($columnFilter instanceof Initializable) {
$columnFilter->initialize();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Display/DisplayTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace SleepingOwl\Admin\Display;

use Illuminate\Contracts\Support\Renderable;
use Illuminate\Contracts\Validation\Validator;
use SleepingOwl\Admin\Contracts\DisplayInterface;
use SleepingOwl\Admin\Contracts\FormInterface;
use SleepingOwl\Admin\Contracts\Initializable;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Contracts\DisplayInterface;

// TODO: починить указание активности таба
class DisplayTab implements Renderable, DisplayInterface, FormInterface
class DisplayTab implements DisplayInterface, FormInterface
{

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ public function setClass($class)
*/
public function initialize()
{
if ($this->getContent() instanceof DisplayInterface) {
if ($this->getContent() instanceof Initializable) {
$this->getContent()->initialize();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Display/DisplayTabbed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace SleepingOwl\Admin\Display;

use Closure;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Contracts\Validation\Validator;
use SleepingOwl\Admin\Contracts\FormInterface;
use SleepingOwl\Admin\Contracts\Initializable;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Contracts\DisplayInterface;

class DisplayTabbed implements Renderable, DisplayInterface, FormInterface
class DisplayTabbed implements DisplayInterface, FormInterface
{
/**
* Added tabs.
Expand All @@ -20,7 +20,7 @@ class DisplayTabbed implements Renderable, DisplayInterface, FormInterface
public function initialize()
{
foreach ($this->getTabs() as $tab) {
if ($tab instanceof DisplayInterface) {
if ($tab instanceof Initializable) {
$tab->initialize();
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/Display/DisplayTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use SleepingOwl\Admin\TableColumn;
use Illuminate\Database\Eloquent\Builder;
use SleepingOwl\Admin\Traits\HtmlAttributes;
use Illuminate\Contracts\Support\Renderable;
use SleepingOwl\Admin\Contracts\Initializable;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Repository\BaseRepository;
use SleepingOwl\Admin\Contracts\FilterInterface;
Expand All @@ -18,7 +18,7 @@
use SleepingOwl\Admin\Contracts\NamedColumnInterface;
use SleepingOwl\Admin\Contracts\ColumnActionInterface;

class DisplayTable implements Renderable, DisplayInterface
class DisplayTable implements DisplayInterface
{
use HtmlAttributes;

Expand Down Expand Up @@ -143,7 +143,7 @@ public function initialize()
$this->repository->setWith($this->getWith());
$this->initializeFilters();
foreach ($this->getAllColumns() as $column) {
if ($column instanceof ColumnInterface) {
if ($column instanceof Initializable) {
$column->initialize();
}
}
Expand Down Expand Up @@ -533,9 +533,11 @@ protected function initializeFilters()
$this->initializeAction();

foreach ($this->getFilters() as $filter) {
$filter->initialize();
if ($filter->isActive()) {
$this->activeFilters[] = $filter;
if ($filter instanceof FilterInterface) {
$filter->initialize();
if ($filter->isActive()) {
$this->activeFilters[] = $filter;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Display/DisplayTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use Meta;
use Route;
use Request;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\TableColumn;
use Illuminate\Contracts\Support\Renderable;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Repository\TreeRepository;
use SleepingOwl\Admin\Contracts\DisplayInterface;
use SleepingOwl\Admin\Contracts\WithRoutesInterface;

class DisplayTree implements Renderable, DisplayInterface, WithRoutesInterface
class DisplayTree implements DisplayInterface, WithRoutesInterface
{
public static function registerRoutes()
{
Expand Down Expand Up @@ -73,6 +72,7 @@ public function initialize()

$this->repository = new TreeRepository($this->class);
$this->repository->with($this->getWith());

TableColumn::treeControl()->initialize();
}

Expand Down
4 changes: 1 addition & 3 deletions src/Form/FormButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace SleepingOwl\Admin\Form;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Traits\HtmlAttributes;
use SleepingOwl\Admin\Contracts\FormButtonsInterface;

class FormButtons implements Renderable, Arrayable, FormButtonsInterface
class FormButtons implements FormButtonsInterface
{
use HtmlAttributes;

Expand Down
6 changes: 3 additions & 3 deletions src/Form/FormDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Request;
use Validator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Support\Renderable;
use SleepingOwl\Admin\Contracts\Initializable;
use SleepingOwl\Admin\Contracts\FormInterface;
use SleepingOwl\Admin\Model\ModelConfiguration;
use SleepingOwl\Admin\Repository\BaseRepository;
Expand All @@ -19,7 +19,7 @@
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class FormDefault implements Renderable, DisplayInterface, FormInterface
class FormDefault implements DisplayInterface, FormInterface
{
/**
* View to render.
Expand Down Expand Up @@ -399,7 +399,7 @@ protected function initializeItems()
$items = $this->getItems();

array_walk_recursive($items, function ($item) {
if ($item instanceof FormElementInterface) {
if ($item instanceof Initializable) {
$item->initialize();
}
});
Expand Down

0 comments on commit 1c4e21d

Please sign in to comment.