示例#1
0
 /**
  * Process - or update - a given node.
  *
  * Provides common processing for both touch and update commands.
  *
  * @param OutputInterface $output     used for status updates.
  * @param NodeInterface   $node       the node to manipulate.
  * @param array           $operations to execute on that node.
  */
 public function processNode(OutputInterface $output, NodeInterface $node, array $operations)
 {
     $operations = array_merge(array('setProp' => array(), 'removeProp' => array(), 'addMixins' => array(), 'removeMixins' => array(), 'applyClosures' => array(), 'dump' => false), $operations);
     foreach ($operations['setProp'] as $set) {
         $parts = explode('=', $set);
         $output->writeln(sprintf('<comment> > Setting property </comment>%s<comment> to </comment>%s', $parts[0], $parts[1]));
         $node->setProperty($parts[0], $parts[1]);
     }
     foreach ($operations['removeProp'] as $unset) {
         $output->writeln(sprintf('<comment> > Unsetting property </comment>%s', $unset));
         $node->setProperty($unset, null);
     }
     foreach ($operations['addMixins'] as $addMixin) {
         $output->writeln(sprintf('<comment> > Adding mixin </comment>%s', $addMixin));
         $node->addMixin($addMixin);
     }
     foreach ($operations['removeMixins'] as $removeMixin) {
         $output->writeln(sprintf('<comment> > Removing mixin </comment>%s', $removeMixin));
         $node->removeMixin($removeMixin);
     }
     foreach ($operations['applyClosures'] as $closure) {
         if ($closure instanceof \Closure) {
             $output->writeln('<comment> > Applying closure</comment>');
         } else {
             $closureString = $closure;
             $closure = create_function('$session, $node', $closure);
             $output->writeln(sprintf('<comment> > Applying closure: %s</comment>', strlen($closureString) > 75 ? substr($closureString, 0, 72) . '...' : $closureString));
         }
         $closure($this->session, $node);
     }
     if ($operations['dump']) {
         $output->writeln('<info>Node dump: </info>');
         /** @var $property PropertyInterface */
         foreach ($node->getProperties() as $property) {
             $value = $property->getValue();
             if (!is_string($value)) {
                 $value = print_r($value, true);
             }
             $output->writeln(sprintf('<comment> - %s = </comment>%s', $property->getName(), $value));
         }
     }
 }
示例#2
0
文件: SuluNode.php 项目: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function removeMixin($mixinName)
 {
     return $this->node->removeMixin($mixinName);
 }