diff --git a/src/Frozennode/Administrator/Actions/Factory.php b/src/Frozennode/Administrator/Actions/Factory.php index 057dc2b..dab1516 100755 --- a/src/Frozennode/Administrator/Actions/Factory.php +++ b/src/Frozennode/Administrator/Actions/Factory.php @@ -172,7 +172,7 @@ public function getByName($name, $global = false) public function getActions($override = false) { //make sure we only run this once and then return the cached version - if (!sizeof($this->actions) || $override) { + if (empty($this->actions) || $override) { $this->actions = array(); //loop over the actions to build the list @@ -194,7 +194,7 @@ public function getActions($override = false) public function getActionsOptions($override = false) { //make sure we only run this once and then return the cached version - if (!sizeof($this->actionsOptions) || $override) { + if (empty($this->actionsOptions) || $override) { $this->actionsOptions = array(); //loop over the actions to build the list @@ -216,7 +216,7 @@ public function getActionsOptions($override = false) public function getGlobalActions($override = false) { //make sure we only run this once and then return the cached version - if (!sizeof($this->globalActions) || $override) { + if (empty($this->globalActions) || $override) { $this->globalActions = array(); //loop over the actions to build the list @@ -238,7 +238,7 @@ public function getGlobalActions($override = false) public function getGlobalActionsOptions($override = false) { //make sure we only run this once and then return the cached version - if (!sizeof($this->globalActionsOptions) || $override) { + if (empty($this->globalActionsOptions) || $override) { $this->globalActionsOptions = array(); //loop over the global actions to build the list @@ -260,7 +260,7 @@ public function getGlobalActionsOptions($override = false) public function getActionPermissions($override = false) { //make sure we only run this once and then return the cached version - if (!sizeof($this->actionPermissions) || $override) { + if (empty($this->actionPermissions) || $override) { $this->actionPermissions = array(); $model = $this->config->getDataModel(); $options = $this->config->getOption('action_permissions'); diff --git a/src/Frozennode/Administrator/DataTable/Columns/Factory.php b/src/Frozennode/Administrator/DataTable/Columns/Factory.php index db91a17..0aa8f88 100755 --- a/src/Frozennode/Administrator/DataTable/Columns/Factory.php +++ b/src/Frozennode/Administrator/DataTable/Columns/Factory.php @@ -200,7 +200,7 @@ public function parseOptions($name, $options) public function getColumns() { //make sure we only run this once and then return the cached version - if (!sizeof($this->columns)) { + if (empty($this->columns)) { foreach ($this->config->getOption('columns') as $name => $options) { //if only a string value was supplied, may sure to turn it into an array $object = $this->make($this->parseOptions($name, $options)); @@ -219,7 +219,7 @@ public function getColumns() public function getColumnOptions() { //make sure we only run this once and then return the cached version - if (!sizeof($this->columnOptions)) { + if (empty($this->columnOptions)) { foreach ($this->getColumns() as $column) { $this->columnOptions[] = $column->getOptions(); } @@ -238,7 +238,7 @@ public function getColumnOptions() public function getIncludedColumns(array $fields) { //make sure we only run this once and then return the cached version - if (!sizeof($this->includedColumns)) { + if (empty($this->includedColumns)) { $model = $this->config->getDataModel(); foreach ($this->getColumns() as $column) { @@ -273,7 +273,7 @@ public function getIncludedColumns(array $fields) public function getRelatedColumns() { //make sure we only run this once and then return the cached version - if (!sizeof($this->relatedColumns)) { + if (empty($this->relatedColumns)) { foreach ($this->getColumns() as $column) { if ($column->getOption('is_related')) { $this->relatedColumns[$column->getOption('column_name')] = $column->getOption('column_name'); @@ -292,7 +292,7 @@ public function getRelatedColumns() public function getComputedColumns() { //make sure we only run this once and then return the cached version - if (!sizeof($this->computedColumns)) { + if (empty($this->computedColumns)) { foreach ($this->getColumns() as $column) { if (!$column->getOption('is_related') && $column->getOption('is_computed')) { $this->computedColumns[$column->getOption('column_name')] = $column->getOption('column_name'); diff --git a/src/Frozennode/Administrator/DataTable/Columns/Relationships/BelongsTo.php b/src/Frozennode/Administrator/DataTable/Columns/Relationships/BelongsTo.php index 28e5d78..c389d47 100755 --- a/src/Frozennode/Administrator/DataTable/Columns/Relationships/BelongsTo.php +++ b/src/Frozennode/Administrator/DataTable/Columns/Relationships/BelongsTo.php @@ -29,8 +29,8 @@ public function build() $this->tablePrefix = $this->db->getTablePrefix(); $nested = $this->getNestedRelationships($options['relationship']); - $relevantName = $nested['pieces'][sizeof($nested['pieces']) - 1]; - $relevantModel = $nested['models'][sizeof($nested['models']) - 2]; + $relevantName = $nested['pieces'][!empty($nested['pieces']) - 1]; + $relevantModel = $nested['models'][!empty($nested['models']) - 2]; $options['nested'] = $nested; $relationship = $relevantModel->{$relevantName}(); @@ -56,7 +56,7 @@ public function getNestedRelationships($name) { $pieces = explode('.', $name); $models = array(); - $num_pieces = sizeof($pieces); + $num_pieces = !empty($pieces); //iterate over the relationships to see if they're all valid foreach ($pieces as $i => $rel) { @@ -89,7 +89,7 @@ public function filterQuery(&$selects) $joins = $where = ''; $columnName = $this->getOption('column_name'); $nested = $this->getOption('nested'); - $num_pieces = sizeof($nested['pieces']); + $num_pieces = !empty($nested['pieces']); //if there is more than one nested relationship, we need to join all the tables if ($num_pieces > 1) { diff --git a/src/Frozennode/Administrator/Fields/Factory.php b/src/Frozennode/Administrator/Fields/Factory.php index 742c853..b11e3d4 100755 --- a/src/Frozennode/Administrator/Fields/Factory.php +++ b/src/Frozennode/Administrator/Fields/Factory.php @@ -360,7 +360,7 @@ public function findFilter($field) */ public function getEditFields($loadRelationships = true, $override = false) { - if (!sizeof($this->editFields) || $override) { + if (empty($this->editFields) || $override) { $this->editFields = array(); //iterate over each supplied edit field @@ -453,7 +453,7 @@ public function getFilters() $configFilters = $this->config->getOption('filters'); //make sure that the filters array hasn't been created before and that there are supplied filters in the config - if (!sizeof($this->filters) && $configFilters) { + if (empty($this->filters) && $configFilters) { //iterate over the filters and create field objects for them foreach ($configFilters as $name => $filter) { if ($fieldObject = $this->make($name, $filter)) { @@ -473,7 +473,7 @@ public function getFilters() */ public function getFiltersArrays() { - if (!sizeof($this->filtersArrays)) { + if (empty($this->filtersArrays)) { foreach ($this->getFilters() as $name => $filter) { $this->filtersArrays[$name] = $filter->getOptions(); } @@ -548,7 +548,7 @@ public function updateRelationshipOptions($field, $type, $constraints, $selected //if this is an autocomplete field, check if there is a search term. If not, just return the selected items if ($fieldObject->getOption('autocomplete') && !$term) { - if (sizeof($selectedItems)) { + if (!empty($selectedItems)) { $this->filterQueryBySelectedItems($query, $selectedItems, $fieldObject, $relatedKeyTable); return $this->formatSelectOptions($fieldObject, $query->get()); @@ -653,11 +653,11 @@ public function applyConstraints($constraints, EloquentBuilder &$query, Field $f { $configConstraints = $fieldObject->getOption('constraints'); - if (sizeof($configConstraints)) { + if (!empty($configConstraints)) { //iterate over the config constraints foreach ($configConstraints as $key => $relationshipName) { //now that we're looping through the constraints, check to see if this one was supplied - if (isset($constraints[$key]) && $constraints[$key] && sizeof($constraints[$key])) { + if (isset($constraints[$key]) && $constraints[$key] && !empty($constraints[$key])) { //first we get the other model and the relationship field on it $model = $this->config->getDataModel(); $relatedModel = $model->{$fieldObject->getOption('field_name')}()->getRelated(); diff --git a/src/Frozennode/Administrator/Fields/Relationships/Relationship.php b/src/Frozennode/Administrator/Fields/Relationships/Relationship.php index 5ae1c82..38d076f 100755 --- a/src/Frozennode/Administrator/Fields/Relationships/Relationship.php +++ b/src/Frozennode/Administrator/Fields/Relationships/Relationship.php @@ -95,7 +95,7 @@ public function setUpConstraints(&$options) $model = $this->config->getDataModel(); //set up and check the constraints - if (sizeof($constraints)) { + if (!empty($constraints)) { $validConstraints = array(); //iterate over the constraints and only include the valid ones diff --git a/tests/DataTable/Columns/Relationships/BelongsToTest.php b/tests/DataTable/Columns/Relationships/BelongsToTest.php index 59a394c..2a7824c 100755 --- a/tests/DataTable/Columns/Relationships/BelongsToTest.php +++ b/tests/DataTable/Columns/Relationships/BelongsToTest.php @@ -107,7 +107,7 @@ public function testGetNestedRelationshipsSingle() $this->assertEquals($nested['pieces'], array($name)); $this->assertEquals($nested['models'][0], $stub); - $this->assertEquals(sizeof($nested['models']), 2); + $this->assertEquals(!empty($nested['models']), 2); } public function testGetNestedRelationshipsNest() @@ -119,7 +119,7 @@ public function testGetNestedRelationshipsNest() $this->assertEquals($nested['pieces'], array('bt', 'btnest')); $this->assertEquals($nested['models'][0], $stub); - $this->assertEquals(sizeof($nested['models']), 3); + $this->assertEquals(!empty($nested['models']), 3); } public function testGetNestedRelationshipsDeepNest() @@ -131,7 +131,7 @@ public function testGetNestedRelationshipsDeepNest() $this->assertEquals($nested['pieces'], array('bt', 'btnest', 'btdeepnest')); $this->assertEquals($nested['models'][0], $stub); - $this->assertEquals(sizeof($nested['models']), 4); + $this->assertEquals(!empty($nested['models']), 4); } /**