Пример #1
0
 /**
  * Tests whether isOfElementType works as expected.
  *
  * @return void
  */
 public function testIsOfElementType()
 {
     $stdClassObjectSet = new ObjectSet(stdClass::class);
     $this->assertTrue($stdClassObjectSet->isOfElementType(stdClass::class));
     $objectSet = new ObjectSet();
     $this->assertFalse($objectSet->isOfElementType(stdClass::class));
 }
 /**
  * Returns all enabled session validators.
  *
  * @return \Ableron\Lib\Collections\Implementations\ObjectSet
  */
 protected function getValidators()
 {
     if ($this->validators === null) {
         // init object set of validators
         $this->validators = new ObjectSet(ValidatorInterface::class);
         // get setting keys
         $settingKeySessionInactivityTimeoutValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.inactivityTimeoutValidator.isEnabled' : 'session.backend.inactivityTimeoutValidator.isEnabled';
         $settingKeySessionUserAgentValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.userAgentValidator.isEnabled' : 'session.backend.userAgentValidator.isEnabled';
         $settingKeySessionIpAddressValidatorEnabled = Application::getRequestHandler()->isFrontendRequest() ? 'session.frontend.ipAddressValidator.isEnabled' : 'session.backend.ipAddressValidator.isEnabled';
         // handle inactivity timeout validator
         if (Application::getConfig()->get($settingKeySessionInactivityTimeoutValidatorEnabled)) {
             $this->validators->add(new InactivityTimeoutValidator());
         }
         // handle user agent validator
         if (Application::getConfig()->get($settingKeySessionUserAgentValidatorEnabled)) {
             $this->validators->add(new UserAgentValidator());
         }
         // handle IP address validator
         if (Application::getConfig()->get($settingKeySessionIpAddressValidatorEnabled)) {
             $this->validators->add(new IpAddressValidator());
         }
     }
     return $this->validators;
 }
Пример #3
0
 /**
  * Sets post-filter plugins.
  *
  * Throws an exception in case the given post-filters are not of type
  * \Ableron\Core\Template\Plugins\Interfaces\PostFilterPluginInterface.
  *
  * @param \Ableron\Lib\Collections\Implementations\ObjectSet $postFilters Post-filter plugins to apply after the actual compilation
  * @throws \Ableron\Core\Exception\SystemException
  * @return void
  */
 private function setPostFilters(ObjectSet $postFilters)
 {
     // check element type of object set
     if (!$postFilters->isOfElementType(PostFilterPluginInterface::class)) {
         throw new SystemException(sprintf('Unable to set post-filter plugins: Plugins not of type %s', PostFilterPluginInterface::class), 0, E_USER_ERROR, __FILE__, __LINE__);
     }
     $this->postFilters = $postFilters;
 }