Example #1
0
 public function validate()
 {
     $result = parent::validate();
     $settings = $this->getSettingsValues();
     if (isset($settings['field_settings'])) {
         $field = $this->getField($this->getSettingsValues());
         $settings_result = $field->validateSettingsForm($settings['field_settings']);
         if ($settings_result instanceof ValidationResult && $settings_result->failed()) {
             foreach ($settings_result->getFailed() as $name => $rules) {
                 foreach ($rules as $rule) {
                     $result->addFailed($name, $rule);
                 }
             }
         }
     }
     return $result;
 }
Example #2
0
 public function getInverse(Model $model)
 {
     $inverse_name = $this->getInverseName();
     return $model->getAssociation($inverse_name);
 }
Example #3
0
 /**
  *
  */
 public function markLinkAsClean(Model $source, Model $target)
 {
     list($_, $to) = $this->getKeys();
     $target->markAsClean($to);
 }
Example #4
0
 /**
  *
  */
 public function markLinkAsClean(Model $source, Model $target)
 {
     list($from, $_) = $this->getKeys();
     $source->markAsClean($from);
 }
Example #5
0
 protected function constrainQueryToSelf($query)
 {
     if ($this->isDirty('site_id')) {
         throw new LogicException('Cannot modify site_id.');
     }
     $query->filter('site_id', $this->site_id);
     parent::constrainQueryToSelf($query);
 }
Example #6
0
 /**
  * Prep the model associations
  *
  * @param Model $model  Model to initialize
  */
 protected function initializeAssociationsOn(Model $model)
 {
     $relations = $this->getAllRelations($model->getName());
     foreach ($relations as $name => $relation) {
         $assoc = $relation->createAssociation($model);
         $model->setAssociation($name, $assoc);
     }
 }
Example #7
0
 /**
  * Returns the propety value using the overrides if present
  *
  * @param str $name The name of the property to fetch
  * @throws InvalidArgumentException if the property does not exist
  * @return mixed The value of the property
  */
 public function __get($name)
 {
     $value = parent::__get($name);
     // Check if have an override for this directory and that it's an
     // array (as it should be)
     if (isset($this->_property_overrides[$this->id]) && is_array($this->_property_overrides[$this->id]) && array_key_exists($name, $this->_property_overrides[$this->id])) {
         $value = $this->_property_overrides[$this->id][$name];
     }
     return $value;
 }