Beispiel #1
0
 /**
  * @return array
  */
 public function getField()
 {
     $findBelongsTo = $this->objectManager->getRepository('BigfishEavBundle:ModuleHasField')->findOneRelatedModule($this->field, $this->module);
     $relatedModule = $findBelongsTo->getBelongsTo();
     $query = $this->objectRepository->getRepository($relatedModule)->setClass(new EavModuleRepository())->findByNotDeleted();
     $options = $findBelongsTo->getOptions() ? $findBelongsTo->getOptions() : array();
     if (!array_key_exists('choiceItemLabel', $options)) {
         throw new \Exception('choiceItemLabel is required');
     }
     $choices = array();
     foreach ($query as $item) {
         $choices[$item['container_id']] = $this->parser->parse($options['choiceItemLabel'], array('row' => $item));
     }
     if (array_key_exists('multiple', $options)) {
         $this->typeChoice['multiple'] = (bool) $options['multiple'];
     }
     if (array_key_exists('expanded', $options)) {
         $this->typeChoice['expanded'] = (bool) $options['expanded'];
     }
     return array('identifier' => $this->field->getIdentifier(), 'formType' => new RelatedContainerType($choices, $this->typeChoice), 'formAttributes' => array('label' => $this->field->getName(), 'attr' => array('help_text' => $this->field->getDescription())));
 }
Beispiel #2
0
 protected function getCallable(Field $field, $row, $value)
 {
     $callback = $field->getFormatValueCallback();
     $reflection = new \ReflectionFunction($callback);
     if ($reflection->getNumberOfParameters() == 1) {
         $value = $callback($value);
     } elseif ($reflection->getNumberOfParameters() == 2) {
         $value = $callback($value, $row);
     } else {
         throw new DataGridException('Wrong number of parameters in the callback for field ' . $field->getFieldName());
     }
     $rowValue = isset($row[$field->getFieldName()]) ? $row[$field->getFieldName()] : null;
     //        if($field->getIsTwig()){
     $value = $this->parser->parse($value, array('value' => $rowValue, 'row' => $row));
     //        }
     return $value;
 }
 public function validateSlug($routePath, $routeData)
 {
     $current = end($routeData);
     array_pop($routeData);
     $explodeSlugs = explode("/", preg_replace('/\\s+/', '', $routePath));
     $arr = array();
     foreach ($explodeSlugs as $checkSlug) {
         $pos = strpos($checkSlug, "{{entities");
         if ($pos !== false) {
             $explodeOnDots = explode(".", $checkSlug);
             if (isset($explodeOnDots[1]) && isset($routeData[$explodeOnDots[1]])) {
                 $arr[] = $checkSlug;
             }
         } else {
             $arr[] = $checkSlug;
         }
     }
     $path = $this->parser->parse(implode("/", $arr), array("current" => $current, "entities" => $routeData));
     return ltrim($path, "/");
     //        return ltrim("/", $path);
 }