/** * 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); }
public function testOffsetExists() { $ar = new ArrayObject(); $ar['foo'] = 'bar'; $ar->bar = 'baz'; $this->assertTrue($ar->offsetExists('foo')); $this->assertFalse($ar->offsetExists('bar')); $this->assertTrue(isset($ar->bar)); $this->assertFalse(isset($ar->foo)); }
/** * @param SmartServiceInterface $smartServiceInterface * @param ArrayObject $config * * @return $this */ private function injectQueryProvider(SmartServiceInterface $smartServiceInterface, ArrayObject $config) { if (!$smartServiceInterface instanceof QueryProviderAwareInterface) { return $this; } if ($config->offsetExists($this::CONFIG_OPTIONS) && count($config[$this::CONFIG_OPTIONS]) < 1) { return $this; } $options = $config[$this::CONFIG_OPTIONS]; if (!isset($options['query-provider'])) { return $this; } $queryProvider = $this->getServiceLocator()->get($options['query-provider']); $smartServiceInterface->setQueryProvider($queryProvider); return $this; }