/** * Returns the system setting entity with the given name. * * Throws an exception in case the requested setting does not exist. * * @param string $settingName Name of the setting to return the entity of * @throws \Ableron\Core\Exception\SystemException * @return \Ableron\Modules\Core\Model\Entities\SettingEntity */ public function getSettingEntity(string $settingName) { if (!$this->settings->containsKey($settingName)) { throw new SystemException(sprintf('Unable to read system setting "%s" - Setting does not exist!', $settingName), 0, E_USER_ERROR, __FILE__, __LINE__); } return $this->settings->get($settingName); }
/** * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::getArgument() */ public function getArgument($argumentName) { // check whether argument is defined if (!$this->tagArguments->containsKey($argumentName)) { throw new SystemException(sprintf('Unable to read argument "%s" of tag {%s} - Argument is not defined for this tag!', $argumentName, $this->getTag()->getTagName()), 0, E_USER_ERROR, __FILE__, __LINE__); } // return requested argument return $this->tagArguments->get($argumentName); }
/** * Fires an event which then will be dispatched to all event handlers * registered for the event. * * First executes all event handlers listening implicitly on the fired event * (i.e. event handlers registered to listen on event "*"). * Then executes all event handlers listening explicitly on the fired event. * * In case an event handler is registered to listen on event "*" and * additionally registered to listen explicitly on an event, the event * handler will be executed multiple times. * * @param \Ableron\Lib\Event\EventInterface $event The event to fire * @return void */ public function fireEvent(EventInterface $event) { foreach (array('*', $event->getName()) as $eventName) { if ($this->eventHandlers->containsKey($eventName)) { /** @var \Ableron\Lib\Event\EventHandlerInterface $eventHandler */ foreach ($this->eventHandlers->get($eventName) as $eventHandler) { $eventHandler->handle($event); } } } }
/** * @see \Ableron\Core\Form\FormInterface::getOpenTag() */ public function getOpenTag() { // get form attributes $formAttributes = $this->attributes->toArray(); // if name is set but and id is not, treat element name as id if (!$this->attributes->containsKey('id') && $this->attributes->containsKey(self::ATTR_NAME)) { $formAttributes['id'] = $this->attributes->get([self::ATTR_NAME]); } // declare attribute strings $attributeStrings = array(); // build attribute string foreach ($formAttributes as $formAttributeName => $formAttributeValue) { // make key lower case $formAttributeName = StringUtil::toLowerCase($formAttributeName); // skip boolean attributes which values are "false" (false = default) if ($formAttributeValue === false) { continue; } // compose attribute $attributeStrings[] = sprintf('%s="%s"', StringUtil::encodeHtml($formAttributeName), StringUtil::encodeHtml($formAttributeValue)); } // build final HTML tag return sprintf('<form %s>', implode(' ', $attributeStrings)); }
/** * Returns an instance of the compiler plugin with the given class name. * * Does not contain error handling for the case, the plugin could not be found because this * method only gets called for plugin which already have been found. * * @param string $pluginClassName Class name of the template plugin * @param \Ableron\Core\Template\TemplateTag $templateTag The template tag to get the compiler plugin for * @return \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface */ private function getCompilerPlugin($pluginClassName, TemplateTag $templateTag) { // build cache key $pluginKey = $pluginClassName . $templateTag->getFullTag(); // find and initialize plugin if not already done if (!$this->compilerPluginInstances->containsKey($pluginKey)) { foreach ($this->pluginDirectories as $pluginDirectory => $namespace) { if (is_file(sprintf('%s/%s.php', $pluginDirectory, $pluginClassName))) { $this->compilerPluginInstances->set($pluginKey, ClassUtil::getInstance($namespace . '\\' . $pluginClassName, array($templateTag))); break; } } } // return compiler plugin return $this->compilerPluginInstances->get($pluginKey); }
/** * @see \Ableron\Lib\Storage\AbstractStorage::performContains() */ protected function performContains(string $storageKey) { return $this->arrayStorage->containsKey($storageKey) && !$this->arrayStorage->get($storageKey)->isExpired(); }
/** * @see \Ableron\Core\Form\FormElementInterface::getLabelOption() */ public function getLabelOption($optionName) { return $this->labelOptions->get($optionName); }
/** * Tests whether set() works as expected. * * @return void */ public function testSet() { $map = new OrderedMap(); $map->set('foo', 'bar'); $this->assertTrue($map->containsKey('foo')); $this->assertTrue($map->containsValue('bar')); $this->assertSame('bar', $map->get('foo')); $map->set('foo', 'baz'); $this->assertTrue($map->containsKey('foo')); $this->assertTrue($map->containsValue('baz')); $this->assertSame('baz', $map->get('foo')); $map->set(0, 42); $this->assertTrue($map->containsKey(0)); $this->assertTrue($map->containsValue(42)); $this->assertSame(42, $map->get(0)); $map->set(0, 'foo'); $this->assertSame('foo', $map->get(0)); }