/**
  * @param NodeDefinition $node
  * @param string         $driver
  * @param string         $option
  *
  * @return self
  */
 private function validateDriver(NodeDefinition $node, $driver, $option)
 {
     $node->validate()->ifTrue(function ($v) use($driver, $option) {
         return $driver === $v['driver'] && empty($v['options'][$option]);
     })->thenInvalid(sprintf('The "%s" option must be defined when using the "%s" driver.', $option, $driver))->end();
     return $this;
 }
 /**
  * {@inheritDoc}
  */
 public function addConfiguration(NodeDefinition $builder)
 {
     $builder->validate()->always(function ($v) {
         if (!empty($v['acl']) && !empty($v['users'])) {
             throw new \Exception('"acl", and "users" cannot be set both at the same time.');
         }
         return $v;
     })->end()->fixXmlConfig('user')->children()->scalarNode('amazon_s3_id')->isRequired()->cannotBeEmpty()->end()->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()->scalarNode('acl')->cannotBeEmpty()->end()->arrayNode('users')->prototype('array')->validate()->always(function ($v) {
         if (!empty($v['group']) === !empty($v['id'])) {
             throw new \Exception('Either "group", or "id" must be set.');
         }
         return $v;
     })->end()->children()->scalarNode('group')->cannotBeEmpty()->end()->scalarNode('id')->cannotBeEmpty()->end()->scalarNode('permission')->isRequired()->cannotBeEmpty()->end()->end()->end()->end()->booleanNode('create')->defaultFalse()->end()->arrayNode('options')->children()->booleanNode('create')->defaultFalse()->end()->scalarNode('region')->end()->scalarNode('directory')->end()->end()->end()->end();
 }
Exemple #3
0
 /**
  * Add rules to sort items by 'order' attribute
  *
  * @param NodeDefinition $node
  */
 protected function addItemsSorting(NodeDefinition $node)
 {
     $node->validate()->always(function ($v) {
         return $this->sortItems($v);
     })->end();
 }