/** * @param Params $defaultOptions * @param Params $extraOptions * @return Params */ protected function getMergedOptions(Params $defaultOptions, Params $extraOptions = null) { if ($extraOptions !== null) { $defaultOptions->merge($extraOptions); } return $defaultOptions; }
/** * @param Params $params * @param Form $form * @param \FzyAuth\Service\Password\Reset $reset * @return \Zend\Http\Response|ViewModel */ protected function preReset(Params $params, Form $form, \FzyAuth\Service\Password\Reset $reset) { if (!trim($params->get('token')) || $reset->getUserByToken($params->get('token'))->isNull()) { return $this->redirect()->toRoute(UserController::ROUTE_LOGIN); } $form->setData($params->get()); $view = new ViewModel(array('changePasswordForm' => $form)); $view->setTemplate('fzy-auth/password/reset'); return $view; }
/** * @param Params $params * * @return Resource * @throws MalformedResourceException */ public static function create(Params $params) { if ($params->has(static::KEY_RESOURCE)) { return new Resource($params->get(static::KEY_RESOURCE), $params->get(static::KEY_PRIVILEGES)); } elseif ($params->has(static::KEY_CONTROLLER)) { return new Resource(AclEnforcerInterface::RESOURCE_CONTROLLER_PREFIX . $params->get(static::KEY_CONTROLLER), $params->get(static::KEY_ACTIONS)); } elseif ($params->has(static::KEY_ROUTE)) { return new Resource(AclEnforcerInterface::RESOURCE_ROUTE_PREFIX . $params->get(static::KEY_ROUTE), $params->get(static::KEY_ACTIONS)); } throw new MalformedResourceException("Invalid ACL resource configuration"); }
/** * @param Params $roleConfig * * @return ZendAcl */ public function createAcl(Params $roleConfig, ServiceLocatorInterface $sm) { $acl = new ZendAcl(); // add all roles from config foreach ($roleConfig->get('roles', array()) as $roleName => $roleData) { $roleMap = Params::create($roleData); $role = new \Zend\Permissions\Acl\Role\GenericRole($roleName); $acl->addRole($role, $roleMap->get('inherits', array())); // add resources from config foreach ($roleMap->get('allow', array()) as $resourceData) { $this->addAllowedResource($acl, $role, AclResource::create(Params::create($resourceData))); } // add denies foreach ($roleMap->get('deny', array()) as $resourceData) { $this->addDeniedResource($acl, $role, AclResource::create(Params::create($resourceData))); } } // trigger event for post-resource setup return $acl; }
/** * @return Params */ protected function getParamsFromRequest() { return Params::create($this->params(), $this->getRequest()); }
<?php namespace FzyCommon; use Aws\S3\S3Client; use Doctrine\Common\Cache\ArrayCache; use FzyCommon\Service\Base; return array('service_manager' => array('invokables' => array('FzyCommon\\Service\\EntityToForm' => 'FzyCommon\\Service\\EntityToForm', 'FzyCommon\\Service\\Search\\Result' => 'FzyCommon\\Service\\Search\\Result', 'FzyCommon\\Service\\Url' => 'FzyCommon\\Service\\Url', 'FzyCommon\\Service\\Render' => 'FzyCommon\\Service\\Render'), 'aliases' => array('FzyCommon\\EntityToForm' => 'FzyCommon\\Service\\EntityToForm', 'FzyCommon\\Search\\Result' => 'FzyCommon\\Service\\Search\\Result', 'FzyCommon\\Url' => 'FzyCommon\\Service\\Url', 'FzyCommon\\Render' => 'FzyCommon\\Service\\Render'), 'factories' => array('FzyCommon\\Config' => function ($sm) { return \FzyCommon\Util\Params::create($sm->get('config')); }, 'FzyCommon\\ModuleConfig' => function ($sm) { return $sm->get('FzyCommon\\Config')->getWrapped(Base::MODULE_CONFIG_KEY); }, 'FzyCommon\\Service\\Aws\\Config' => function ($sm) { return $sm->get('FzyCommon\\ModuleConfig')->getWrapped('aws'); }, 'FzyCommon\\Service\\Aws\\S3\\Config' => function ($sm) { return $sm->get('FzyCommon\\Service\\Aws\\Config')->getWrapped('s3'); }, 'FzyCommon\\Service\\Aws\\S3' => function ($sm) { return S3Client::factory($sm->get('FzyCommon\\Service\\Aws\\S3\\Config')->get()); }, 'FzyCommon\\Factory\\DoctrineCache' => function ($sm) { /* @var $config \FzyCommon\Util\Params */ $config = $sm->get('FzyCommon\\ModuleConfig'); if ($config->get('production') && class_exists('Redis')) { try { $redisConfig = $config->getWrapped('doctrine_cache_config'); $cache = new \Doctrine\Common\Cache\RedisCache(); $redis = new \Redis(); $redis->connect($redisConfig->get('host', '127.0.0.1'), $redisConfig->get('port', 6379), $redisConfig->get('timeout', 5)); $cache->setRedis($redis); return $cache; } catch (\Exception $e) { if ($config->get('debug')) { throw $e;
/** * Creates body of reset email based on settings. * @param UserInterface $user * @return string */ protected function renderMessageContent(UserInterface $user) { $viewFile = $this->getOptions()->get('view'); $viewVars = Params::create(array('user' => $user, 'resetUrl' => $this->url()->fromRoute('fzyauth-password/reset/get', array('token' => $user->getPasswordToken()), array('force_canonical' => true)))); // $viewVars->merge(); // render view return $this->getServiceLocator()->get('FzyCommon\\Render')->handle($viewFile, $viewVars->get()); }
/** * @param $key * @param array $default * * @return Params */ public function getWrapped($key, $default = array()) { return Params::create($this->get($key, $default)); }
/** * Convenience method to add an AND WHERE IN clause in a common format. * If $queryParameterName is unspecified, $requestParameterName is used for both * * @param Params $params * @param QueryBuilder $qb * @param $requestParameterName * @param null $queryParameterName * @return $this */ protected function addWhereInFilter(Params $params, QueryBuilder $qb, $requestParameterName, $queryParameterName = null) { if ($queryParameterName === null) { $queryParameterName = $requestParameterName; } if ($params->has($requestParameterName)) { $qb->andWhere($qb->expr()->in($this->alias($queryParameterName), ':' . $requestParameterName))->setParameter($requestParameterName, $params->get($requestParameterName)); } return $this; }
/** * Handler for subform data * @param $tag * @param $paramName * @return $this */ public function setSubFormDataHandler($tag, $paramName) { $this->formDataEvent($tag, function (Params $params) use($paramName) { return Params::create($params->get($paramName)); }); return $this; }
public function editAction() { $params = Params::create($this->params(), $this->getRequest()); $service = $this->getUpdateService($params); return new ViewModel(array('form' => $service->form(), 'entity' => $service->entity())); }
/** * Returns whether, based on the Param values * the * @param Params $params * @return bool */ protected function isSingular(Params $params) { return $params->has($this->getIdParam()); }