Inheritance: extends eZ\Publish\API\Repository\Values\Content\Content
Esempio n. 1
0
 /**
  * @covers \eZ\Publish\Core\Repository\Values\Content\Content::getProperties
  */
 public function testObjectProperties()
 {
     $object = new Content(array('internalFields' => array()));
     $properties = $object->attributes();
     self::assertNotContains('internalFields', $properties, 'Internal property found ');
     self::assertContains('id', $properties, 'Property not found ');
     self::assertContains('fields', $properties, 'Property not found ');
     self::assertContains('versionInfo', $properties, 'Property not found ');
     self::assertContains('contentInfo', $properties, 'Property not found ');
     // check for duplicates and double check existence of property
     $propertiesHash = array();
     foreach ($properties as $property) {
         if (isset($propertiesHash[$property])) {
             self::fail("Property '{$property}' exists several times in properties list");
         } elseif (!isset($object->{$property})) {
             self::fail("Property '{$property}' does not exist on object, even though it was hinted to be there");
         }
         $propertiesHash[$property] = 1;
     }
 }
 /**
  * Compute Meta by reference
  *
  * @param Content      $content
  * @param string|Field $fieldDefIdentifier
  * @param ContentType  $contentType
  * @param bool         $needFallback
  *
  * @return Meta[]
  */
 protected function innerComputeMetas(Content $content, $fieldDefIdentifier, ContentType $contentType, &$needFallback = false)
 {
     if ($fieldDefIdentifier instanceof Field) {
         $metasFieldValue = $fieldDefIdentifier->value;
         $fieldDefIdentifier = $fieldDefIdentifier->fieldDefIdentifier;
     } else {
         $metasFieldValue = $content->getFieldValue($fieldDefIdentifier);
     }
     if ($metasFieldValue instanceof MetasFieldValue) {
         $metasConfig = $this->configResolver->getParameter('fieldtype_metas', 'novae_zseo');
         // as the configuration is the last fallback we need to loop on it.
         foreach ($metasConfig as $metaName => $metasSettings) {
             if ($metasFieldValue->nameExists($metaName)) {
                 $meta = $metasFieldValue->metas[$metaName];
             } else {
                 $meta = new Meta($metaName);
                 $metasFieldValue->metas[$metaName] = $meta;
             }
             /** @var Meta $meta */
             if ($meta->isEmpty()) {
                 $meta->setContent($metasConfig[$meta->getName()]['default_pattern']);
                 $fieldDefinition = $contentType->getFieldDefinition($fieldDefIdentifier);
                 $configuration = $fieldDefinition->getFieldSettings()['configuration'];
                 // but if we need something is the configuration we take it
                 if ($configuration[$meta->getName()]) {
                     $meta->setContent($configuration[$meta->getName()]);
                 }
             }
             if (!$this->metaNameSchema->resolveMeta($meta, $content, $contentType)) {
                 $needFallback = true;
             }
         }
         return $metasFieldValue->metas;
     }
     return [];
 }
 /**
  * Get the selection field from a content object
  * 
  * @param \eZ\Publish\Core\Repository\Values\Content\Content $content
  * @param string $fieldIdentifier
  * @return \eZ\Publish\API\Repository\Values\Content\Field
  */
 protected function getTranslatedContentFieldSelection( $content, $fieldIdentifier )
 {
     $field = $content->getFieldValue($fieldIdentifier);
     if( is_object($field) )
     {
         return $field->selection;
     }
     return false;
 }