Example #1
0
 /**
  * @param mixed $parent
  * @param mixed $value
  * @param mixed $by
  */
 public function __construct($parent, $value = null, $by = null)
 {
     $this->type = static::TYPE;
     parent::__construct($this->type, $parent, $value, $by);
 }
Example #2
0
File: Meta.php Project: nabble/ajde
 public function getMetaFields($crossReferenceTable, $crossReferenceField, $sortField, $parentField, $filters = [])
 {
     $allFields = [];
     $metas = new MetaCollection();
     $metas->concatCrossReference($crossReferenceTable, $crossReferenceField);
     $metas->concatField($crossReferenceTable, $sortField);
     if (!empty($filters)) {
         $group = new Ajde_Filter_WhereGroup();
         foreach ($filters as $filter) {
             if ($filter instanceof Ajde_Filter_Where) {
                 $group->addFilter($filter);
             } else {
                 $metas->addFilter($filter);
             }
         }
         $metas->addFilter($group);
     }
     foreach ($metas as $meta) {
         $metaField = $this->getType($meta->get('type'));
         $fieldOptions = $metaField->getMetaField($meta);
         // add show only when
         foreach (explode(',', $meta->get($crossReferenceField)) as $parentValue) {
             $fieldOptions->addShowOnlyWhen($parentField, $parentValue);
         }
         // add sorting
         foreach (explode(',', $meta->get($sortField)) as $parentValue) {
             $fieldOptions->addDynamicSort($parentField, $parentValue);
         }
         $allFields['meta_' . $meta->getPK()] = $fieldOptions;
     }
     return $allFields;
 }