コード例 #1
0
 /**
  * Asks, "is the key locked?" and if not, sets it.
  *
  * @param string $key
  * @param AbstractTerm $term
  * @throws \Exception
  * @return mixed Lock\Handle or false
  */
 public function takeLock($key, AbstractTerm $term)
 {
     if (strstr($key, $this->options->getSeparator())) {
         throw new Exception\RuntimeException('key contained reserved separator');
     }
     $this->adapter->beginTransaction();
     try {
         $clearKey = $this->adapter->getOptions()->getClearAllIsCheap() ? null : $key;
         $this->adapter->clearExpiredLock($clearKey);
         /**
          * Failure may very well throw exceptions.
          */
         $result = $this->adapter->setLock($key, $term->getEndDate());
         if ($result instanceof Lock\Handle) {
             $this->adapter->commit();
             if ($this->options->getVerifyLock() && !$this->adapter->verifyLock($result)) {
                 throw new Exception\PhantomLockException();
             }
             return $result;
         }
     } catch (Exception\PhantomLockException $e) {
         throw $e;
     } catch (\Exception $e) {
         $this->adapter->rollback();
         throw $e;
     }
     $this->adapter->rollback();
     return false;
 }
コード例 #2
0
 /**
  * Configure the Form width Options
  *
  * @param \Core\Form\Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     $size = $options->getCompanyLogoMaxSize();
     $type = $options->getCompanyLogoMimeType();
     $form->get($this->fileName)->setViewHelper('FormImageUpload')->setMaxSize($size)->setAllowedTypes($type)->setForm($form);
     $form->setIsDescriptionsEnabled(true);
     $form->setDescription('Choose a Logo. This logo will be shown in the job opening and the application form.');
 }
コード例 #3
0
ファイル: OptionsMap.php プロジェクト: leodido/conversio
 /**
  * Ctor
  *
  * @param  array|\Traversable|null $options
  * @throws Exception\DomainException
  */
 public function __construct($options = null)
 {
     if (!ArrayUtils::isHashTable($this->config, false)) {
         throw new Exception\DomainException(sprintf('"%s" expects that options map configuration property is an hash table', __METHOD__));
     }
     parent::__construct($options);
 }
コード例 #4
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     if (!$this->modulesPath) {
         $this->modulesPath = getcwd() . '/module';
     }
 }
コード例 #5
0
ファイル: CallbackOptions.php プロジェクト: gridguyz/zork
 /**
  * Constructor
  *
  * @param  callable|array|Traversable|null  $options
  */
 public function __construct($options = null)
 {
     if (is_callable($options)) {
         $options = array('callback' => $options);
     }
     parent::__construct($options);
 }
コード例 #6
0
ファイル: MongoDBOptions.php プロジェクト: tejdeeps/tejcs.com
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     if ($this->saveOptions === array('w' => 1) && version_compare(phpversion('mongo'), '1.3.0', '<')) {
         $this->saveOptions = array('safe' => true);
     }
 }
コード例 #7
0
ファイル: Error.php プロジェクト: Kipperlenny/ZendRestModule
 public function __construct($options = null)
 {
     parent::__construct($options);
     if (is_null($this->getOnError())) {
         $this->setOnError(function () {
         });
     }
 }
コード例 #8
0
ファイル: AttachmentsFactory.php プロジェクト: vfulco/YAWIK
 /**
  * configure the formular for uploading attachments
  *
  * @param Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     $form->setIsDisableCapable(false)->setIsDisableElementsCapable(false)->setIsDescriptionsEnabled(true)->setDescription('Attach images or PDF Documents to your application. Drag&drop them, or click into the attachement area. You can upload up to 5MB')->setParam('return', 'file-uri')->setLabel('Attachments');
     /** @var $file FileUpload*/
     $file = $form->get($this->fileName);
     /** @var ModuleOptions $options */
     $size = $options->getAttachmentsMaxSize();
     $type = $options->getAttachmentsMimeType();
     $count = $options->getAttachmentsCount();
     $file->setMaxSize($size);
     if ($type) {
         $file->setAllowedTypes($type);
     }
     $file->setMaxFileCount($count);
     // pass form to element. Needed for file count validation
     // I did not find another (better) way.
     $file->setForm($form);
 }
コード例 #9
0
 /**
  * Override AbstractOptions::__set
  *
  * Validates value if save options are being set.
  *
  * @param string $key
  * @param mixed $value
  */
 public function __set($key, $value)
 {
     if (strtolower($key) !== 'saveoptions') {
         return parent::__set($key, $value);
     }
     if (!is_array($value)) {
         throw new InvalidArgumentException('Expected array for save options');
     }
     $this->setSaveOptions($value);
 }
コード例 #10
0
 /**
  * configure the formular for uploading attachments
  *
  * @param Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     if (!$options instanceof ModuleOptions) {
         throw new \InvalidArgumentException(sprintf('$options must be instance of %s', ModuleOptions::class));
     }
     $size = $options->getAttachmentsMaxSize();
     $type = $options->getAttachmentsMimeType();
     $count = $options->getAttachmentsCount();
     $form->setIsDisableCapable(false)->setIsDisableElementsCapable(false)->setIsDescriptionsEnabled(true)->setDescription('Attach images or PDF Documents to your CV. Drag&drop them, or click into the attachement area. You can upload up to %sMB', [round($size / (1024 * 1024)) > 0 ? round($size / (1024 * 1024)) : round($size / (1024 * 1024), 1)])->setParam('return', 'file-uri')->setLabel('Attachments');
     /* @var $file \Core\Form\Element\FileUpload */
     $file = $form->get($this->fileName);
     $file->setMaxSize($size);
     if ($type) {
         $file->setAllowedTypes($type);
     }
     $file->setMaxFileCount($count);
     // pass form to element. Needed for file count validation
     // I did not find another (better) way.
     $file->setForm($form);
 }
コード例 #11
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     foreach ($this->handlers as $index => $handlerOptions) {
         if (is_string($handlerOptions)) {
             continue;
         }
         if (!is_array($handlerOptions)) {
             throw new \Exception('Invalid Handler Config', 500);
         }
         $this->handlers[$index] = new MonologHandlerOptions($handlerOptions);
     }
 }
コード例 #12
0
 public function __construct($options = [])
 {
     $defaults = ['errors' => [], 'controllers' => [], 'serializer' => []];
     // We need to set these options before regular
     // hydration, because some nested options objects
     // share these configs with us.
     if (isset($options['cache_dir'])) {
         $this->setCacheDir($options['cache_dir']);
     }
     if (isset($options['debug'])) {
         $this->setDebug($options['debug']);
     }
     parent::__construct(array_replace($defaults, $options));
 }
コード例 #13
0
ファイル: Conversion.php プロジェクト: leodido/conversio
 /**
  * @return AbstractOptions
  */
 public function getAdapterOptions()
 {
     if (is_array($this->adapterOptions)) {
         $optClass = $this->getAbstractOptions();
         $this->adapterOptions = $optClass->setFromArray($this->adapterOptions);
         return $this->adapterOptions;
     }
     $wantedOptionsClass = self::getOptionsFullQualifiedClassName($this->adapter);
     if (get_class($this->adapterOptions) !== $wantedOptionsClass) {
         throw new Exception\DomainException(sprintf('"%s" expects that options set are an array or a valid "%s" instance; received "%s"', __METHOD__, $wantedOptionsClass, get_class($this->adapterOptions)));
     }
     $this->options = $this->adapterOptions->toArray();
     return $this->adapterOptions;
 }
コード例 #14
0
 public function __construct($options)
 {
     $this->rootModuleDir = getcwd() . '/data/VisoftMailerModule';
     $this->logDir = $this->rootModuleDir . '/log';
     $this->contactExportedCsvDir = $this->rootModuleDir . '/contacts/exported-csv';
     $this->contactUploadedCsvDir = $this->rootModuleDir . '/contacts/uploaded-csv';
     $this->contactReportsDir = $this->rootModuleDir . '/contacts/reports';
     $this->contactEnterJsonDir = $this->rootModuleDir . '/contacts/enter-json';
     $this->mailingContactsJsonDir = $this->rootModuleDir . '/mailing/contacts-json';
     $this->mailingReportsDir = $this->rootModuleDir . '/mailing/reports';
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->rootModuleDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->logDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->contactExportedCsvDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->contactUploadedCsvDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->contactReportsDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->contactEnterJsonDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->mailingContactsJsonDir);
     \VisoftBaseModule\Controller\Plugin\AccessoryPlugin::checkDir($this->mailingReportsDir);
     parent::__construct($options);
 }
コード例 #15
0
ファイル: PatternOptions.php プロジェクト: idwsdta/INIT-frame
 /**
  * Constructor
  *
  * @param  array|Traversable|null $options
  * @return PatternOptions
  * @throws Exception\InvalidArgumentException
  */
 public function __construct($options = null)
 {
     // disable file/directory permissions by default on windows systems
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $this->filePermission = false;
         $this->dirPermission = false;
     }
     parent::__construct($options);
 }
コード例 #16
0
ファイル: ModuleOptions.php プロジェクト: joacub/zfj-rbac
 /**
  * Constructor
  *
  * {@inheritDoc}
  */
 public function __construct($options = null)
 {
     $this->__strictMode__ = false;
     parent::__construct($options);
 }
コード例 #17
0
 /**
  * Constructor
  * 
  * @param array|\Traversable|null $options
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
 }
コード例 #18
0
 public function __construct(array $options = [])
 {
     parent::__construct($this->normalizeOptions($options));
 }
コード例 #19
0
ファイル: Options.php プロジェクト: DavidHavl/Ajasta
 /**
  * @param array|Traversable|null $options
  */
 public function __construct($options = null)
 {
     $this->dataPath = __DIR__ . '/../../../data';
     $this->countryCodesPath = __DIR__ . '/../../../data/country-codes.php';
     parent::__construct($options);
 }
コード例 #20
0
ファイル: DomainOptions.php プロジェクト: Ellipizle/LosDomain
 /**
  * Constructor
  * @param array  $options Array with the options
  * @param string $domain  The domain
  */
 public function __construct($options, $domain)
 {
     parent::__construct($options);
     $this->domain = $domain;
 }
コード例 #21
0
ファイル: Metadata.php プロジェクト: andreas-serlo/athene2
 public function __construct(array $data)
 {
     parent::__construct($data);
     $this->creationDate = $this->creationDate ? $this->creationDate : new DateTime();
     $this->lastModified = $this->lastModified ? $this->lastModified : new DateTime();
 }
コード例 #22
0
ファイル: Config.php プロジェクト: enlitepro/zf2-scaffold
 /**
  * @param array|Traversable|AbstractOptions $options
  * @return AbstractOptions
  */
 public function setFromArray($options)
 {
     foreach (array_keys($options) as $key) {
         if (strpos($key, 'no-') === 0 || strpos($key, 'only-') === 0) {
             unset($options[$key]);
         }
     }
     return parent::setFromArray($options);
 }
コード例 #23
0
 /**
  * Constructor
  *
  * @param  array|\Traversable|null $options
  */
 public function __construct($options = null)
 {
     $this->type = AMQP_EX_TYPE_DIRECT;
     parent::__construct($options);
 }
コード例 #24
0
 public function __construct(array $options = [])
 {
     $this->basePath = __DIR__ . '/../files';
     parent::__construct($options);
 }
コード例 #25
0
 public function __construct($options = null)
 {
     if (!empty($options['parent_options'])) {
         // this should not be used I guess..
         $parentOptions = new static($options['parent_options']);
         $options['parent_options'] = $parentOptions;
     }
     if (!empty($options['child_options'])) {
         $childOptions = array();
         foreach ($options['child_options'] as $key => $option) {
             if (!empty($options['child_options']['route_base'])) {
                 // ignore route base on children
                 $options['child_options']['route_base'] = null;
             }
             $child = new static($option);
             $child->setParentOptions($this);
             if (empty($child->getParentAttributeName())) {
                 $child->setParentAttributeName(lcfirst($options['name']));
             }
             $childOptions[$key] = $child;
         }
         $options['child_options'] = $childOptions;
     }
     parent::__construct($options);
     // generate missing values
     if (empty($this->listTitle)) {
         $this->listTitle = gettext_noop('%ss');
     }
     if (empty($this->buttonTitle)) {
         $this->buttonTitle = $this->name;
     }
     if (empty($this->editTitle)) {
         $this->editTitle = gettext_noop('Edit %s');
     }
     if (empty($this->createTitle)) {
         $this->createTitle = gettext_noop('Create %s');
     }
     if (empty($this->deleteWarningText)) {
         $this->deleteWarningText = gettext_noop('Really delete %s?');
     }
     if (empty($this->createText)) {
         $this->createText = gettext_noop('Add new %s');
     }
     if ($this->pageLength === null) {
         $this->pageLength = 10;
     }
     if (empty($this->aliasParamName)) {
         $this->aliasParamName = strtolower($this->name) . '_alias';
     }
     if (empty($this->idParamName)) {
         $this->idParamName = strtolower($this->name) . '_id';
     }
     if (empty($this->idName)) {
         $this->idName = 'id';
     }
     if (empty($this->aliasName)) {
         $this->aliasName = 'alias';
     }
     if (empty($this->listRoute)) {
         $this->setListRoute(array());
     }
     if (empty($this->createRoute)) {
         $this->setCreateRoute(array());
     }
     if (empty($this->editRoute)) {
         $this->setEditRoute(array());
     }
     if (empty($this->deleteRoute)) {
         $this->setDeleteRoute(array());
     }
     if (empty($this->entityClass) && !empty($this->baseNamespace)) {
         $this->entityClass = $this->baseNamespace . "\\Entity\\" . $this->name;
     }
     if (empty($this->formClass) && !empty($this->baseNamespace)) {
         $this->formClass = $this->baseNamespace . "\\Form\\" . $this->name . "Form";
     }
 }
コード例 #26
0
 /**
  * {@inheritDoc}
  *
  * Normalizes dash-separated keys to underscore-separated to ensure
  * backwards compatibility with old options (even though dash-separated
  * were previously ignored!).
  *
  * @see \Zend\Stdlib\ParameterObject::__get()
  * @param string $key
  * @throws \Zend\Stdlib\Exception\BadMethodCallException
  * @return mixed
  */
 public function __get($key)
 {
     return parent::__get(str_replace('-', '_', $key));
 }
コード例 #27
0
ファイル: UserImageFactory.php プロジェクト: utrenkner/YAWIK
 /**
  * Configure the file upload formular with Applications/Options
  *
  * @param Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     /** @var ModuleOptions $options */
     $form->get($this->fileName)->setViewHelper('FormImageUpload')->setMaxSize($options->getContactImageMaxSize())->setAllowedTypes($options->getContactImageMimeType())->setForm($form);
 }
コード例 #28
0
ファイル: Options.php プロジェクト: antoinebon/zf2
 public function __construct($config, \ZendDeveloperTools\Options $zdtOptions)
 {
     $this->zdtOptions = $zdtOptions;
     return parent::__construct($config);
 }
コード例 #29
0
ファイル: Options.php プロジェクト: DavidHavl/Ajasta
 /**
  * @param array|Traversable|null $options
  */
 public function __construct($options = null)
 {
     $this->xslPath = __DIR__ . '/../../../examples/invoice.xsl';
     $this->translationPath = __DIR__ . '/../../../examples/translations';
     parent::__construct($options);
 }
コード例 #30
0
ファイル: Options.php プロジェクト: rafajaques/colloquium
 /**
  * Overloading Constructor.
  *
  * @param  array|Traversable|null $options
  * @param  ReportInterface        $report
  * @throws \Zend\Stdlib\Exception\InvalidArgumentException
  */
 public function __construct($options = null, ReportInterface $report)
 {
     $this->report = $report;
     parent::__construct($options);
 }