allowProperties() public method

Example: allowProperties('title', 'content', 'author')
public allowProperties ( ) : PropertyMappingConfiguration
return PropertyMappingConfiguration this
 /**
  * Modify the passed $propertyMappingConfiguration according to the $propertyConfiguration which
  * has been generated by Fluid. In detail, if the $propertyConfiguration contains
  * an __identity field, we allow modification of objects; else we allow creation.
  *
  * All other properties are specified as allowed properties.
  *
  * @param array $propertyConfiguration
  * @param PropertyMappingConfiguration $propertyMappingConfiguration
  * @return void
  */
 protected function modifyPropertyMappingConfiguration($propertyConfiguration, PropertyMappingConfiguration $propertyMappingConfiguration)
 {
     if (!is_array($propertyConfiguration)) {
         return;
     }
     if (isset($propertyConfiguration['__identity'])) {
         $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
         unset($propertyConfiguration['__identity']);
     } else {
         $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
     }
     foreach ($propertyConfiguration as $innerKey => $innerValue) {
         if (is_array($innerValue)) {
             $this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey));
         }
         $propertyMappingConfiguration->allowProperties($innerKey);
     }
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function convertSkipsUnknownPropertiesIfConfiguredTo()
 {
     $source = ['firstProperty' => 1, 'secondProperty' => 2];
     $typeConverters = ['array' => ['stdClass' => [10 => $this->getMockTypeConverter('array2object', true, $source, 'integer')]], 'integer' => ['integer' => [10 => $this->getMockTypeConverter('integer2integer')]]];
     $configuration = new PropertyMappingConfiguration();
     $propertyMapper = $this->getAccessibleMock(PropertyMapper::class, ['dummy']);
     $propertyMapper->_set('typeConverters', $typeConverters);
     $propertyMapper->convert($source, 'stdClass', $configuration->allowProperties('firstProperty')->skipUnknownProperties());
     // dummy assertion to avoid PHPUnit warning
     $this->assertTrue(true);
 }
 /**
  * @test
  * @covers \Neos\Flow\Property\PropertyMappingConfiguration::shouldMap
  */
 public function shouldMapReturnsTrueForAllowedProperties()
 {
     $this->propertyMappingConfiguration->allowProperties('someSourceProperty', 'someOtherProperty');
     $this->assertTrue($this->propertyMappingConfiguration->shouldMap('someSourceProperty'));
     $this->assertTrue($this->propertyMappingConfiguration->shouldMap('someOtherProperty'));
 }