Exemple #1
3
 /**
  * Saves default_billing and default_shipping flags for customer address
  *
  * @param array $addressIdList
  * @param array $extractedCustomerData
  * @return array
  */
 protected function saveDefaultFlags(array $addressIdList, array &$extractedCustomerData)
 {
     $result = [];
     $extractedCustomerData[CustomerInterface::DEFAULT_BILLING] = null;
     $extractedCustomerData[CustomerInterface::DEFAULT_SHIPPING] = null;
     foreach ($addressIdList as $addressId) {
         $scope = sprintf('address/%s', $addressId);
         $addressData = $this->_extractData($this->getRequest(), 'adminhtml_customer_address', \Magento\Customer\Api\AddressMetadataInterface::ENTITY_TYPE_ADDRESS, ['default_billing', 'default_shipping'], $scope);
         if (is_numeric($addressId)) {
             $addressData['id'] = $addressId;
         }
         // Set default billing and shipping flags to customer
         if (!empty($addressData['default_billing']) && $addressData['default_billing'] === 'true') {
             $extractedCustomerData[CustomerInterface::DEFAULT_BILLING] = $addressId;
             $addressData['default_billing'] = true;
         } else {
             $addressData['default_billing'] = false;
         }
         if (!empty($addressData['default_shipping']) && $addressData['default_shipping'] === 'true') {
             $extractedCustomerData[CustomerInterface::DEFAULT_SHIPPING] = $addressId;
             $addressData['default_shipping'] = true;
         } else {
             $addressData['default_shipping'] = false;
         }
         $result[] = $addressData;
     }
     return $result;
 }
 /**
  * Parses a token and returns a node.
  *
  * @param  \Twig_Token $token A Twig_Token instance
  *
  * @return \Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $vars = new \Twig_Node_Expression_Array(array(), $lineno);
     $body = null;
     $count = $this->parser->getExpressionParser()->parseExpression();
     $domain = new \Twig_Node_Expression_Constant('messages', $lineno);
     if (!$stream->test(\Twig_Token::BLOCK_END_TYPE) && $stream->test('for')) {
         // {% transchoice count for "message" %}
         // {% transchoice count for message %}
         $stream->next();
         $body = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('with')) {
         // {% transchoice count with vars %}
         $stream->next();
         $vars = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('from')) {
         // {% transchoice count from "messages" %}
         $stream->next();
         $domain = $this->parser->getExpressionParser()->parseExpression();
     }
     if (null === $body) {
         // {% transchoice count %}message{% endtranschoice %}
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
         $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
     }
     if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
         throw new \Twig_Error_Syntax(sprintf('A message must be a simple text (line %s)', $lineno), -1);
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new TransNode($body, $domain, $count, $vars, $lineno, $this->getTag());
 }
Exemple #3
1
 /**
  * @param EveApiReadWriteInterface $data
  * @param EveApiRetrieverInterface $retrievers
  * @param EveApiPreserverInterface $preservers
  * @param int                      $interval
  *
  * @throws LogicException
  */
 public function autoMagic(EveApiReadWriteInterface $data, EveApiRetrieverInterface $retrievers, EveApiPreserverInterface $preservers, $interval)
 {
     $this->getLogger()->debug(sprintf('Starting autoMagic for %1$s/%2$s', $this->getSectionName(), $this->getApiName()));
     /**
      * Update Industry Jobs History
      */
     $class = new IndustryJobsHistory($this->getPdo(), $this->getLogger(), $this->getCsq());
     $class->autoMagic($data, $retrievers, $preservers, $interval);
     $active = $this->getActiveCharacters();
     if (0 === count($active)) {
         $this->getLogger()->info('No active characters found');
         return;
     }
     foreach ($active as $char) {
         $data->setEveApiSectionName(strtolower($this->getSectionName()))->setEveApiName($this->getApiName());
         if ($this->cacheNotExpired($this->getApiName(), $this->getSectionName(), $char['characterID'])) {
             continue;
         }
         $data->setEveApiArguments($char)->setEveApiXml();
         if (!$this->oneShot($data, $retrievers, $preservers, $interval)) {
             continue;
         }
         $this->updateCachedUntil($data->getEveApiXml(), $interval, $char['characterID']);
     }
 }
Exemple #4
1
 public function getScriptingLogAction()
 {
     $this->request->restrictAccess(Acl::RESOURCE_LOGS_SCRIPTING_LOGS);
     $this->request->defineParams(['executionId' => ['type' => 'string']]);
     $info = $this->db->GetRow("SELECT * FROM scripting_log WHERE execution_id = ? LIMIT 1", [$this->getParam('executionId')]);
     if (!$info) {
         throw new Exception('Script execution log not found');
     }
     try {
         $dbServer = DBServer::LoadByID($info['server_id']);
         if (!in_array($dbServer->status, [SERVER_STATUS::INIT, SERVER_STATUS::RUNNING])) {
             throw new Exception();
         }
     } catch (Exception $e) {
         throw new Exception('This server has been terminated and its logs are no longer available');
     }
     //Note! We should not check not-owned-farms permission here. It's approved by Igor.
     if ($dbServer->envId != $this->environment->id) {
         throw new \Scalr_Exception_InsufficientPermissions();
     }
     $logs = $dbServer->scalarizr->system->getScriptLogs($this->getParam('executionId'));
     $msg = sprintf("STDERR:\n%s \n\n STDOUT:\n%s", base64_decode($logs->stderr), base64_decode($logs->stdout));
     $msg = nl2br(htmlspecialchars($msg));
     $this->response->data(['message' => $msg]);
 }
Exemple #5
1
 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new \ReflectionClass($type);
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
 /**
  * Returns the DataTable associated to the ID $idTable.
  * NB: The datatable has to have been instanciated before!
  * This method will not fetch the DataTable from the DB.
  *
  * @param int $idTable
  * @throws Exception If the table can't be found
  * @return DataTable  The table
  */
 public function getTable($idTable)
 {
     if (!isset($this->tables[$idTable])) {
         throw new TableNotFoundException(sprintf("This report has been reprocessed since your last click. To see this error less often, please increase the timeout value in seconds in Settings > General Settings. (error: id %s not found).", $idTable));
     }
     return $this->tables[$idTable];
 }
 /**
  * @param string                                                    $name
  * @param array                                                     $config
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder   $container
  *
  * @return \Symfony\Component\DependencyInjection\Reference
  */
 private function getConnectionReference($name, array $config, ContainerBuilder $container)
 {
     if (isset($config['connection_id'])) {
         return new Reference($config['connection_id']);
     }
     $host = $config['host'];
     $port = $config['port'];
     $connClass = '%doctrine_cache.redis.connection.class%';
     $connId = sprintf('doctrine_cache.services.%s_redis.connection', $name);
     $connDef = new Definition($connClass);
     $connParams = array($host, $port);
     if (isset($config['timeout'])) {
         $connParams[] = $config['timeout'];
     }
     $connDef->setPublic(false);
     $connDef->addMethodCall('connect', $connParams);
     if (isset($config['password'])) {
         $password = $config['password'];
         $connDef->addMethodCall('auth', array($password));
     }
     if (isset($config['database'])) {
         $database = (int) $config['database'];
         $connDef->addMethodCall('select', array($database));
     }
     $container->setDefinition($connId, $connDef);
     return new Reference($connId);
 }
Exemple #8
1
 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
Exemple #9
1
 /**
  *
  */
 public function testChmod()
 {
     $cache = new FileAdapter(self::$dir, new NoneSerializer(), 0777);
     $cache->set('item', 'content');
     $perms = fileperms(self::$dir . '/' . md5('item'));
     $this->assertEquals('0777', substr(sprintf('%o', $perms), -4));
 }
 /**
  * Assert that after deleting product success message.
  *
  * @param FixtureInterface|FixtureInterface[] $product
  * @param CatalogProductIndex $productPage
  * @return void
  */
 public function processAssert($product, CatalogProductIndex $productPage)
 {
     $products = is_array($product) ? $product : [$product];
     $deleteMessage = sprintf(self::SUCCESS_DELETE_MESSAGE, count($products));
     $actualMessage = $productPage->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals($deleteMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $deleteMessage . "\nActual: " . $actualMessage);
 }
Exemple #11
1
 /**
  * @brief Get the points
  */
 function getPoint($member_srl, $from_db = false)
 {
     $member_srl = abs($member_srl);
     // Get from instance memory
     if (!$from_db && $this->pointList[$member_srl]) {
         return $this->pointList[$member_srl];
     }
     // Get from file cache
     $path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
     $cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
     if (!$from_db && file_exists($cache_filename)) {
         return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
     }
     // Get from the DB
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $output = executeQuery('point.getPoint', $args);
     if (isset($output->data->member_srl)) {
         $point = (int) $output->data->point;
         $this->pointList[$member_srl] = $point;
         if (!is_dir($path)) {
             FileHandler::makeDir($path);
         }
         FileHandler::writeFile($cache_filename, $point);
         return $point;
     }
     return 0;
 }
 /**
  * @param ApplicationInterface $app
  *
  * @throws Exception
  */
 public function run(ApplicationInterface $app)
 {
     $this->application = $app;
     $action = $app->getRequest()->getAction();
     if ($action) {
         $actionMiddleware = new ActionMiddleware(Invokable::cast($action));
         $serviceId = $action instanceof ServiceReference ? $action->getId() : $this->computeServiceName($app->getRequest()->getUri()->getPath());
         $app->getStep('action')->plug($actionMiddleware);
     } else {
         $route = $app->getRequest()->getRoute();
         // compute service id
         $serviceId = $this->computeServiceName($route);
         // if no service matching the route has been registered,
         // try to locate a class that could be used as service
         if (!$app->getServicesFactory()->isServiceRegistered($serviceId)) {
             $actionClass = $this->resolveActionClassName($route);
             $action = $this->resolveActionFullyQualifiedName($actionClass);
             if (!$action) {
                 throw new Exception(sprintf('No callback found to map the requested route "%s"', $route), Exception::ACTION_NOT_FOUND);
             }
             $app->getServicesFactory()->registerService(['id' => $serviceId, 'class' => $action]);
         }
         // replace action by serviceId to ensure it will be fetched using the ServicesFactory
         $actionReference = new ServiceReference($serviceId);
         // wrap action to inject returned value in application
         $app->getStep('action')->plug($actionMiddleware = new ActionMiddleware($actionReference));
     }
     // store action as application parameter for further reference
     $app->setParam('runtime.action.middleware', $actionMiddleware);
     $app->setParam('runtime.action.service-id', $serviceId);
 }
    public function configure()
    {
        $this->setName('phpcr:migrations:migrate');
        $this->addArgument('to', InputArgument::OPTIONAL, sprintf('Version name to migrate to, or an action: "<comment>%s</comment>"', implode('</comment>", "<comment>', $this->actions)));
        $this->setDescription('Migrate the content repository between versions');
        $this->setHelp(<<<EOT
Migrate to a specific version or perform an action.

By default it will migrate to the latest version:

    \$ %command.full_name%

You can migrate to a specific version (either in the "past" or "future"):

    \$ %command.full_name% 201504011200

Or specify an action

    \$ %command.full_name% <action>

Action can be one of:

- <comment>up</comment>: Migrate one version up
- <comment>down</comment>: Migrate one version down
- <comment>top</comment>: Migrate to the latest version
- <comment>bottom</comment>: Revert all migrations

EOT
);
    }
Exemple #14
1
 /**
  * @param string $email
  */
 function __construct($email)
 {
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new \InvalidArgumentException(sprintf('"%s" is not a valid email', $email));
     }
     $this->email = $email;
 }
Exemple #15
0
 public function init()
 {
     $this->settings = get_option('ninja_forms_settings');
     if (!extension_loaded('curl')) {
         throw new Exception(sprintf(__('The cURL extension is not loaded. %sPlease ensure its installed and activated.%s', 'ninja-forms-upload'), '<a href="http://php.net/manual/en/curl.installation.php">', '</a>'));
     }
     $this->oauth = new Dropbox_OAuth_Consumer_Curl(self::CONSUMER_KEY, self::CONSUMER_SECRET);
     $this->oauth_state = $this->get_option('dropbox_oauth_state');
     $this->request_token = $this->get_token('request');
     $this->access_token = $this->get_token('access');
     if ($this->oauth_state == 'request') {
         //If we have not got an access token then we need to grab one
         try {
             $this->oauth->setToken($this->request_token);
             $this->access_token = $this->oauth->getAccessToken();
             $this->oauth_state = 'access';
             $this->oauth->setToken($this->access_token);
             $this->save_tokens();
             //Supress the error because unlink, then init should be called
         } catch (Exception $e) {
         }
     } elseif ($this->oauth_state == 'access') {
         $this->oauth->setToken($this->access_token);
     } else {
         //If we don't have an acess token then lets setup a new request
         $this->request_token = $this->oauth->getRequestToken();
         $this->oauth->setToken($this->request_token);
         $this->oauth_state = 'request';
         $this->save_tokens();
     }
     $this->dropbox = new Dropbox_API($this->oauth);
 }
 /**
  * Tokenize
  * 
  * @param string $action reset|confirm
  * @param string $field password|email
  * @param array $data CakeRequest::data
  * 
  * @return array $user User::find
  */
 public function tokenize(Model $Model, $action, $field, $data = array())
 {
     if (empty($field) || empty($action) || !in_array($field, array('password', 'email')) || !in_array($action, array('reset', 'confirm'))) {
         throw new InvalidArgumentException('Invalid agruments');
     }
     return $this->dispatchMethod('_' . Inflector::variable(sprintf('tokenize_%s_%s', $action, $field)), array($Model, $data));
 }
Exemple #17
0
 /**
  * Handles response for csv-request.
  *
  * @param ViewHandler $handler
  * @param View $view
  * @param Request $request
  * @param string $format
  *
  * @return Response
  *
  * @throws ObjectNotSupportedException
  */
 public function createResponse(ViewHandler $handler, View $view, Request $request, $format)
 {
     if (!$view->getData() instanceof ListRepresentation) {
         throw new ObjectNotSupportedException($view);
     }
     $viewData = $view->getData();
     $data = new CallbackCollection($viewData->getData(), [$this, 'prepareData']);
     $fileName = sprintf('%s.csv', $viewData->getRel());
     $config = new ExporterConfig();
     $exporter = new Exporter($config);
     $data->rewind();
     if ($row = $data->current()) {
         $config->setColumnHeaders(array_keys($row));
     }
     $config->setDelimiter($this->convertValue($request->get('delimiter', ';'), self::$delimiterMap));
     $config->setNewline($this->convertValue($request->get('newLine', '\\n'), self::$newLineMap));
     $config->setEnclosure($request->get('enclosure', '"'));
     $config->setEscape($request->get('escape', '\\'));
     $response = new StreamedResponse();
     $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $fileName, $fileName);
     $response->headers->set('Content-Type', 'text/csv');
     $response->headers->set('Content-Disposition', $disposition);
     $response->setCallback(function () use($data, $exporter) {
         $exporter->export('php://output', $data);
     });
     $response->send();
     return $response;
 }
 /**
  * @param Doctrine\ODM\MongoDB\Document $value
  * @param Constraint $constraint
  * @return Boolean
  */
 public function isValid($document, Constraint $constraint)
 {
     $class = get_class($document);
     $dm = $this->getDocumentManager($constraint);
     $metadata = $dm->getClassMetadata($class);
     if ($metadata->isEmbeddedDocument) {
         throw new \InvalidArgumentException(sprintf("Document '%s' is an embedded document, and cannot be validated", $class));
     }
     $query = $this->getQueryArray($metadata, $document, $constraint->path);
     // check if document exists in mongodb
     if (null === ($doc = $dm->getRepository($class)->findOneBy($query))) {
         return true;
     }
     // check if document in mongodb is the same document as the checked one
     if ($doc === $document) {
         return true;
     }
     // check if returned document is proxy and initialize the minimum identifier if needed
     if ($doc instanceof Proxy) {
         $metadata->setIdentifierValue($doc, $doc->__identifier);
     }
     // check if document has the same identifier as the current one
     if ($metadata->getIdentifierValue($doc) === $metadata->getIdentifierValue($document)) {
         return true;
     }
     $this->context->setPropertyPath($this->context->getPropertyPath() . '.' . $constraint->path);
     $this->setMessage($constraint->message, array('{{ property }}' => $constraint->path));
     return false;
 }
 /**
  * {@inheritDoc}
  */
 public function getStrategy($key)
 {
     if (!isset($this->strategies[$key])) {
         throw new StrategyNotFoundException(sprintf('Not found strategy with key "%s".', $key));
     }
     return $this->strategies[$key];
 }
 protected function save($data)
 {
     global $itsec_lockout;
     $count = 0;
     if (!empty($data['users']) && is_array($data['users'])) {
         foreach ($data['users'] as $id) {
             $result = $itsec_lockout->release_lockout($id);
             $count++;
             if (!$result) {
                 $this->errors[] = sprintf(__('An unknown error prevented releasing the lockout the user with a lockout ID of %d', 'better-wp-security'), $id);
             }
         }
     }
     if (!empty($data['hosts']) && is_array($data['hosts'])) {
         foreach ($data['hosts'] as $id) {
             $result = $itsec_lockout->release_lockout($id);
             $count++;
             if (!$result) {
                 $this->errors[] = sprintf(__('An unknown error prevented releasing the lockout the host with a lockout ID of %d', 'better-wp-security'), $id);
             }
         }
     }
     if (empty($this->errors)) {
         if ($count > 0) {
             $this->messages[] = _n('Successfully removed the selected lockout.', 'Sucessfully remove the selected lockouts.', $count, 'better-wp-security');
         } else {
             $this->messages[] = __('No lockouts were selected for removal.', 'better-wp-security');
         }
     }
 }
 /**
  * Encode a given string to produce an encoded string.
  *
  * @param string  $string
  * @param int     $firstLineOffset if first line needs to be shorter
  * @param int     $maxLineLength   0 indicates the default length for this encoding
  *
  * @return string
  *
  * @throws RuntimeException
  */
 public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
 {
     if ($this->charset !== 'utf-8') {
         throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
     }
     return $this->_standardize(quoted_printable_encode($string));
 }
Exemple #22
0
 public function end()
 {
     $code = '$_translator->setVar(\'%s\', ob_get_contents())';
     $code = sprintf($code, $this->expression);
     $this->tag->generator->pushCode($code);
     $this->tag->generator->pushCode('ob_end_clean()');
 }
 /**
  * {@inheritdoc}
  */
 public function normalize($object, $format = null, array $context = [])
 {
     if (!$this->serializer instanceof NormalizerInterface) {
         throw new \LogicException('Serializer must be a normalizer');
     }
     $data = [];
     if (null !== $object->getFamily()) {
         $data[self::FAMILY_FIELD] = $this->serializer->normalize($object->getFamily(), $format, $context);
     }
     foreach ($object->getGroups() as $group) {
         $data[self::GROUPS_FIELD][] = $this->serializer->normalize($group, $format, $context);
         $inGroupField = sprintf('%s_%d', self::IN_GROUP_FIELD, $group->getId());
         $data[$inGroupField] = true;
     }
     if ($object->getCreated()) {
         $data[self::CREATED_FIELD] = $this->serializer->normalize($object->getCreated(), $format, $context);
     }
     if ($object->getUpdated()) {
         $data[self::UPDATED_FIELD] = $this->serializer->normalize($object->getUpdated(), $format, $context);
     }
     foreach ($object->getValues() as $value) {
         $normalizedData = $this->serializer->normalize($value, $format, $context);
         if (null !== $normalizedData) {
             $data = array_replace($data, $normalizedData);
         }
     }
     $completenesses = [];
     foreach ($object->getCompletenesses() as $completeness) {
         $completenesses = array_merge($completenesses, $this->serializer->normalize($completeness, $format, $context));
     }
     $data[self::COMPLETENESSES_FIELD] = $completenesses;
     $data[self::ENABLED_FIELD] = (bool) $object->isEnabled();
     return $data;
 }
Exemple #24
0
 /**
  * @param int      $expectedType     Expected triggered error type (pass one of PHP's E_* constants)
  * @param string[] $expectedMessages Expected error messages
  * @param callable $testCode         A callable that is expected to trigger the error messages
  */
 public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
 {
     if (!is_callable($testCode)) {
         throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
     }
     $e = null;
     $triggeredMessages = array();
     try {
         $prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
             if ($expectedType !== $type) {
                 return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
             }
             $triggeredMessages[] = $message;
         });
         call_user_func($testCode);
     } catch (\Exception $e) {
     } catch (\Throwable $e) {
     }
     restore_error_handler();
     if (null !== $e) {
         throw $e;
     }
     \PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
     foreach ($triggeredMessages as $i => $message) {
         \PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
     }
 }
Exemple #25
0
 function process($controller)
 {
     $this->_prepareFilter($controller);
     $ret = array();
     if (isset($controller->request->data)) {
         //Loop for models
         foreach ($controller->request->data as $key => $value) {
             if (isset($controller->{$key})) {
                 $columns = $controller->{$key}->getColumnTypes();
                 foreach ($value as $k => $v) {
                     if ($v != '') {
                         //Trim the value
                         $v = trim($v);
                         //Check if there are some fieldFormatting set
                         if (isset($this->fieldFormatting[$columns[$k]])) {
                             $ret[sprintf($this->fieldFormatting[$columns[$k]][0], $key . '.' . $k, $v)] = sprintf($this->fieldFormatting[$columns[$k]][1], $key . '.' . $k, $v);
                         } else {
                             $ret[$key . '.' . $k] = $v;
                         }
                     }
                 }
                 //unsetting the empty forms
                 if (count($value) == 0) {
                     unset($controller->data[$key]);
                 }
             }
         }
     }
     return $ret;
 }
 public function index()
 {
     $this->load->language('payment/authorizenet_aim');
     $data['text_credit_card'] = $this->language->get('text_credit_card');
     $data['text_wait'] = $this->language->get('text_wait');
     $data['entry_cc_owner'] = $this->language->get('entry_cc_owner');
     $data['entry_cc_number'] = $this->language->get('entry_cc_number');
     $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
     $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
     $data['button_confirm'] = $this->language->get('button_confirm');
     $data['months'] = array();
     for ($i = 1; $i <= 12; $i++) {
         $data['months'][] = array('text' => strftime('%B', mktime(0, 0, 0, $i, 1, 2000)), 'value' => sprintf('%02d', $i));
     }
     $today = getdate();
     $data['year_expire'] = array();
     for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
         $data['year_expire'][] = array('text' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)), 'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)));
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl', $data);
     } else {
         return $this->load->view('default/template/payment/authorizenet_aim.tpl', $data);
     }
 }
Exemple #27
0
 public function Services_meta()
 {
     $Services_meta = array('id' => 'Services_section', 'title' => __('Home Page Additional Information', 'SimThemes'), 'desc' => '', 'pages' => array('Service'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('id' => 'service_icon', 'label' => __('Service Icon', 'SimThemes'), 'desc' => sprintf(__('Please select the icon', 'SimThemes')), 'std' => '', 'type' => 'font-awesome', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => ''), array('id' => 'client_Email', 'label' => __('Clint Email', 'SimThemes'), 'desc' => '', 'std' => '', 'type' => 'text', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => '', 'operator' => 'and'), array('id' => 'client_Designation', 'label' => __('Clint Designation', 'SimThemes'), 'desc' => '', 'std' => '', 'type' => 'text', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => '', 'operator' => 'and')));
     if (function_exists('ot_register_meta_box')) {
         ot_register_meta_box($Services_meta);
     }
 }
 public function testSchedule()
 {
     $testIntegrationType = 'testIntegrationType';
     $testConnectorType = 'testConnectorType';
     $testId = 22;
     $integration = new Integration();
     $integration->setType($testIntegrationType);
     $integration->setEnabled(true);
     $ref = new \ReflectionProperty(get_class($integration), 'id');
     $ref->setAccessible(true);
     $ref->setValue($integration, $testId);
     $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType());
     $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector());
     $that = $this;
     $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow));
     $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock();
     $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity')));
     $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
     $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) {
         $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}'];
         $that->assertEquals($expectedArgs, $job->getArgs());
     }));
     $uow->expects($this->once())->method('computeChangeSet');
     $this->scheduler->schedule($integration, $testConnectorType, [], false);
 }
 /**
  * Check if users need to set the file permissions in order to support the theme, and if not, displays warnings messages in admin option page.
  */
 function wt_warnings()
 {
     global $wp_version;
     $warnings = array();
     if (!wt_check_wp_version()) {
         $warnings[] = 'Wordpress version(<b>' . $wp_version . '</b>) is too low. Please upgrade to the latest version.';
     }
     if (!function_exists("imagecreatetruecolor")) {
         $warnings[] = 'GD Library Error: <b>imagecreatetruecolor does not exist</b>. Please contact your host provider and ask them to install the GD library, otherwise this theme won\'t work properly.';
     }
     if (!is_writeable(THEME_CACHE_DIR)) {
         $warnings[] = 'The cache folder (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '</b>) is not writeable. Please set the correct file permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
     }
     if (!file_exists(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
         $warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) doesn\'t exists or it was deleted. Please manually create this file or click on \'Save changes\' and it will be automatically created.';
     }
     if (!is_writeable(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
         $warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) is not writeable. Please set the correct permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
     }
     $str = '';
     if (!empty($warnings)) {
         $str = '<ul>';
         foreach ($warnings as $warning) {
             $str .= '<li>' . $warning . '</li>';
         }
         $str .= '</ul>';
         echo "\r\n\t\t\t\t<div id='theme-warning' class='error fade'><p><strong>" . sprintf(__('%1$s Error Messages', 'wt_admin'), THEME_NAME) . "</strong><br/>" . $str . "</p></div>\r\n\t\t\t";
     }
 }
 public function block_toolbar($context, array $blocks = array())
 {
     // line 4
     echo "    ";
     ob_start();
     // line 5
     echo "        <span>\n            <img width=\"13\" height=\"28\" alt=\"Memory Usage\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAcBAMAAABITyhxAAAAJ1BMVEXNzc3///////////////////////8/Pz////////////+NjY0/Pz9lMO+OAAAADHRSTlMAABAgMDhAWXCvv9e8JUuyAAAAQ0lEQVQI12MQBAMBBmLpMwoMDAw6BxjOOABpHyCdAKRzsNDp5eXl1KBh5oHBAYY9YHoDQ+cqIFjZwGCaBgSpBrjcCwCZgkUHKKvX+wAAAABJRU5ErkJggg==\" />\n            <span>";
     // line 7
     echo twig_escape_filter($this->env, sprintf("%.1f", $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memory") / 1024 / 1024), "html", null, true);
     echo " MB</span>\n        </span>\n    ";
     $context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 10
     echo "    ";
     ob_start();
     // line 11
     echo "        <div class=\"sf-toolbar-info-piece\">\n            <b>Memory usage</b>\n            <span>";
     // line 13
     echo twig_escape_filter($this->env, sprintf("%.1f", $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memory") / 1024 / 1024), "html", null, true);
     echo " / ";
     echo $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memoryLimit") == -1 ? "&infin;" : twig_escape_filter($this->env, sprintf("%.1f", $this->getAttribute(isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memoryLimit") / 1024 / 1024));
     echo " MB</span>\n        </div>\n    ";
     $context["text"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 16
     echo "    ";
     $this->env->loadTemplate("@WebProfiler/Profiler/toolbar_item.html.twig")->display(array_merge($context, array("link" => false)));
 }