/** * Returns the value of a property. * * @param string $name * @return mixed|null */ protected function getProperty($name) { if ($this->properties->offsetExists($name)) { return $this->properties->offsetGet($name); } return null; }
/** * @param ArrayObject $config * * @throws \Phpro\AnnotatedForms\Exception\RuntimeException */ protected function injectListeners(ArrayObject $config) { if (!$config->offsetExists('listeners') || !$config->offsetGet('listeners')) { return; } $listeners = $config->offsetGet('listeners'); foreach ($listeners as $index => $serviceKey) { $listener = $this->getServiceLocator()->get($serviceKey); if (!$listener instanceof ListenerAggregateInterface) { throw new RuntimeException(sprintf('Expected ListenerAggregateInterface for key "%s"', $serviceKey)); } $listeners[$index] = $listener; } $config->offsetSet('listeners', $listeners); }
/** * @param SmartServiceInterface $smartCrudService * @param ArrayObject $config * * @return $this */ private function injectListeners(SmartServiceInterface $smartCrudService, ArrayObject $config) { if ($config->offsetExists($this::CONFIG_LISTENERS_KEY) && count($config[$this::CONFIG_LISTENERS_KEY]) < 1) { return $this; } $serviceLocator = $this->getServiceLocator(); foreach ($config->offsetGet($this::CONFIG_LISTENERS_KEY) as $listener) { $smartCrudService->getEventManager()->attach($serviceLocator->get($listener)); } return $this; }