/** * 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; }
/** * 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.'); }
/** * 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); }
public function __construct($options = null) { parent::__construct($options); if (!$this->modulesPath) { $this->modulesPath = getcwd() . '/module'; } }
/** * Constructor * * @param callable|array|Traversable|null $options */ public function __construct($options = null) { if (is_callable($options)) { $options = array('callback' => $options); } parent::__construct($options); }
/** * {@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); } }
public function __construct($options = null) { parent::__construct($options); if (is_null($this->getOnError())) { $this->setOnError(function () { }); } }
/** * 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); }
/** * 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); }
/** * 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); }
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); } }
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)); }
/** * @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; }
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); }
/** * 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); }
/** * Constructor * * {@inheritDoc} */ public function __construct($options = null) { $this->__strictMode__ = false; parent::__construct($options); }
/** * Constructor * * @param array|\Traversable|null $options */ public function __construct($options = null) { parent::__construct($options); }
public function __construct(array $options = []) { parent::__construct($this->normalizeOptions($options)); }
/** * @param array|Traversable|null $options */ public function __construct($options = null) { $this->dataPath = __DIR__ . '/../../../data'; $this->countryCodesPath = __DIR__ . '/../../../data/country-codes.php'; parent::__construct($options); }
/** * Constructor * @param array $options Array with the options * @param string $domain The domain */ public function __construct($options, $domain) { parent::__construct($options); $this->domain = $domain; }
public function __construct(array $data) { parent::__construct($data); $this->creationDate = $this->creationDate ? $this->creationDate : new DateTime(); $this->lastModified = $this->lastModified ? $this->lastModified : new DateTime(); }
/** * @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); }
/** * Constructor * * @param array|\Traversable|null $options */ public function __construct($options = null) { $this->type = AMQP_EX_TYPE_DIRECT; parent::__construct($options); }
public function __construct(array $options = []) { $this->basePath = __DIR__ . '/../files'; parent::__construct($options); }
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"; } }
/** * {@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)); }
/** * 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); }
public function __construct($config, \ZendDeveloperTools\Options $zdtOptions) { $this->zdtOptions = $zdtOptions; return parent::__construct($config); }
/** * @param array|Traversable|null $options */ public function __construct($options = null) { $this->xslPath = __DIR__ . '/../../../examples/invoice.xsl'; $this->translationPath = __DIR__ . '/../../../examples/translations'; parent::__construct($options); }
/** * 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); }