Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @return Params
  */
 protected function getParamsFromRequest()
 {
     return Params::create($this->params(), $this->getRequest());
 }
Exemplo n.º 3
0
<?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;
Exemplo n.º 4
0
 /**
  * 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());
 }
Exemplo n.º 5
0
 /**
  * @param $key
  * @param array $default
  *
  * @return Params
  */
 public function getWrapped($key, $default = array())
 {
     return Params::create($this->get($key, $default));
 }
Exemplo n.º 6
0
 /**
  * Finds an element in this domain which has the specified ID
  *
  * @param $id
  * @throws NotFound
  * @return \FzyCommon\Entity\BaseInterface
  */
 public function find($id)
 {
     $params = Params::create(array($this->getIdParam() => $id, 'limit' => 1));
     $qb = $this->getCustomizedQueryBuilder($params);
     $results = $this->getQBResult($params, $this->queryHook($params, $qb));
     if ($results->count() != 1) {
         throw new NotFound("Unable to locate entity " . $this->getRepository() . " with id " . $id);
     }
     /* @var $results \Doctrine\ORM\Tools\Pagination\Paginator */
     /**
      * Note: this is a paginator object so the only way to access result elements is by iterating
      */
     foreach ($results as $result) {
         // return the first (and only) result
         return $result;
     }
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
0
 public function editAction()
 {
     $params = Params::create($this->params(), $this->getRequest());
     $service = $this->getUpdateService($params);
     return new ViewModel(array('form' => $service->form(), 'entity' => $service->entity()));
 }