Devise\Pages\Interpreter\DeviseTag::toArray PHP Метод

toArray() публичный Метод

Converts our devise tag into a giant ass array
public toArray ( $escaped = '', $hasKeys = false ) : array
Результат array
    public function toArray($escaped = '', $hasKeys = false)
    {
        $arrayFormat = array('id' => $this->id, 'bindingType' => $this->bindingType, 'collection' => $this->collection, 'key' => $this->key, 'type' => $this->type, 'humanName' => $this->humanName, 'collectionName' => $this->collectionName, 'group' => $this->group, 'category' => $this->category, 'alternateTarget' => $this->alternateTarget, 'defaults' => $this->defaults, 'chain' => $this->chain);
        // walk over the array and churn out a list of string values
        // for each thing and make sure to enclose in \" quotes \"
        array_walk($arrayFormat, function (&$value, $index) use($escaped) {
            if ($value === '' || is_null($value)) {
                $value = 'null';
            }
            if ($value !== 'null' && !empty($escaped) && !in_array($index, ['id', 'defaults', 'chain'])) {
                $value = str_replace($escaped, "\\" . $escaped, $value);
                $value = "{$escaped}{$value}{$escaped}";
            }
        });
        return $hasKeys ? $arrayFormat : array_values($arrayFormat);
    }

Usage Example

Пример #1
0
 /**
  * Creates a string from tag parameters which will be used
  * to rewrite the data-devise html
  *
  * @param  DeviseTag $tag
  * @return string
  */
 protected function getNewDeviseTagString(DeviseTag $tag)
 {
     list($id, $bindingType, $collection, $key, $type, $humanName, $collectionName, $group, $category, $alternateTarget, $defaults, $chain) = $tag->toArray('"');
     if ($bindingType === '"variable"') {
         $key = $chain;
     }
     return " data-devise-<?php echo devise_tag_cid('{$id}', {$bindingType}, {$collection}, {$key}, {$type}, {$humanName}, {$collectionName}, {$group}, {$category}, {$alternateTarget}, {$defaults}) ?>=\"{$id}\"";
 }