Пример #1
0
 protected function validateMetas(Node $node, Node $obj, NodeSchema $schema, $mode)
 {
     $processed_metas = array();
     $metas = $obj->getMetas();
     // Check all metas passed against the meta defs.
     foreach ($metas as $meta) {
         // Ensure the meta has a meta_def
         $meta_def = $schema->getMetaDef($meta->getMetaName());
         $this->getErrors()->rejectIfInvalid($this->resolveField($node->getNodeRef(), $meta->getMetaName(), $obj instanceof Section ? $obj : null), 'meta', $meta_def->Title, $meta->getValue(), $meta_def->Validation);
         $processed_metas[] = $meta->getMetaName();
     }
     $meta_defs = $schema->getMetaDefs();
     // Check all meta defs that haven't been processed
     // These meta defs must only match partials that we have.
     $meta_partials = PartialUtils::unserializeMetaPartials($node->getNodePartials()->getMetaPartials());
     $re_meta_partials = PartialUtils::unserializeMetaPartials($node->getNodePartials()->getRestrictedMetaPartials());
     foreach ($meta_defs as $meta_def) {
         if (in_array($meta_def->Id, $processed_metas)) {
             continue;
         }
         if ($mode == 'edit' && !$this->metaInScope($schema, new Meta($meta_def->Id, ''), $meta_partials, $re_meta_partials)) {
             continue;
         }
         // Validate the meta def with a null value
         $this->getErrors()->rejectIfInvalid($this->resolveField($node->getNodeRef(), $meta_def->Id, $obj instanceof Section ? $obj : null), 'meta', $meta_def->Title, null, $meta_def->Validation);
         $processed_metas[] = $meta_def->Id;
     }
 }
Пример #2
0
 protected function bindAll(Node &$node, NodeSchema &$schema, Errors &$errors, array $fields, array $rawFields)
 {
     foreach ($schema->getTagDefs() as $tagDef) {
         if ($tagDef->Direction == 'in') {
             $this->bindInTags($node, $errors, $fields, $rawFields, $tagDef->Id);
         } else {
             $this->bindOutTags($node, $errors, $fields, $rawFields, $tagDef->Id);
         }
     }
     foreach ($schema->getMetaDefs() as $metaDef) {
         $this->bindMeta($node, $errors, $fields, $rawFields, $metaDef->Id);
     }
 }