_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q1400
Document.processDocument
train
public function processDocument(DocumentEvent $event) { $subdir = $event->getCacheSubdirectory(); $sourceFile = $event->getSourceFilepath(); if (null == $subdir || null == $sourceFile) { throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be ...
php
{ "resource": "" }
q1401
Category.create
train
public function create(CategoryCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $category = new CategoryModel(); $category ->setDispatcher($dispatcher) ->setLocale($event->getLocale()) ->setParent($event->getParent()) ->setVisi...
php
{ "resource": "" }
q1402
Category.update
train
public function update(CategoryUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { $category ->setDispatcher($dispatcher) ->setDefaultTemplateId($event->getDef...
php
{ "resource": "" }
q1403
Category.delete
train
public function delete(CategoryDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { $con = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); $con->beginTransaction(); ...
php
{ "resource": "" }
q1404
Category.toggleVisibility
train
public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $category = $event->getCategory(); $category ->setDispatcher($dispatcher) ->setVisible($category->getVisible() ? false : true) ->save() ...
php
{ "resource": "" }
q1405
Category.viewCheck
train
public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if ($event->getView() == 'category') { $category = CategoryQuery::create() ->filterById($event->getViewId()) ->filterByVisible(1) ->count(); ...
php
{ "resource": "" }
q1406
SiteController.renderToolSiteHeaderAction
train
public function renderToolSiteHeaderAction() { $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $melisKey = $this->params()->fromRoute('melisKey', ''); $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY); $view = new ViewModel(); ...
php
{ "resource": "" }
q1407
SiteController.renderToolSiteModalAddAction
train
public function renderToolSiteModalAddAction() { // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool...
php
{ "resource": "" }
q1408
SiteController.getSiteDomainPlatform
train
public function getSiteDomainPlatform() { $data = array(); if($this->getRequest()->isGet()){ $siteDomain = $this->getServiceLocator()->get('SiteDomain'); $data = $siteDomain->getSiteDomain(); } return $data; }
php
{ "resource": "" }
q1409
SiteController.getSiteEnvironmentAction
train
public function getSiteEnvironmentAction() { $json = array(); $siteId = (int) $this->params()->fromQuery('siteId'); $melisEngineTableSiteDomain = $this->getServiceLocator()->get('MelisEngineTableSiteDomain'); $sitePlatform = $melisEngineTableSiteDomain->getEntryByField('sdom...
php
{ "resource": "" }
q1410
SiteController.getSiteEnvironmentsAction
train
public function getSiteEnvironmentsAction() { $json = array(); $siteId = (int) $this->params()->fromQuery('siteId'); $domainTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $domainData = $domainTable->fetchAll(); $domainData = $domainData->toArray()...
php
{ "resource": "" }
q1411
SiteController.deleteSiteByIdAction
train
public function deleteSiteByIdAction() { $translator = $this->getServiceLocator()->get('translator'); $request = $this->getRequest(); $domainId = null; $success = 0; $textTitle = 'tr_meliscms_tool_site'; $textMessage = ''; $eventDatas = array(); ...
php
{ "resource": "" }
q1412
UseDeclarationNode.setAlias
train
public function setAlias($alias) { if (is_string($alias)) { $alias = new TokenNode(T_STRING, $alias); } if ($alias instanceof TokenNode) { if ($this->hasAlias()) { $this->alias->replaceWith($alias); } else { $this->alias = $alias; $this->addChild(WhitespaceNo...
php
{ "resource": "" }
q1413
UseDeclarationNode.getBoundedName
train
public function getBoundedName() { if ($this->alias) { return $this->alias->getText(); } else { return $this->name->lastChild()->getText(); } }
php
{ "resource": "" }
q1414
Order.orderCartClear
train
public function orderCartClear(/** @noinspection PhpUnusedParameterInspection */ OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher) { // Empty cart and clear current order $session = $this->getSession(); $session->clearSessionCart($dispatcher); $session->setOrder(...
php
{ "resource": "" }
q1415
Order.getStockUpdateOnOrderStatusChange
train
public function getStockUpdateOnOrderStatusChange(GetStockUpdateOperationOnOrderStatusChangeEvent $event, $eventName, EventDispatcherInterface $dispatcher) { // The order $order = $event->getOrder(); // The new order status $newStatus = $event->getNewOrderStatus(); if ($new...
php
{ "resource": "" }
q1416
Order.updateQuantity
train
protected function updateQuantity(ModelOrder $order, $newStatus, EventDispatcherInterface $dispatcher) { if ($newStatus !== $order->getStatusId()) { if (null !== $newStatusModel = OrderStatusQuery::create()->findPk($newStatus)) { $operationEvent = new GetStockUpdateOperationOnOrd...
php
{ "resource": "" }
q1417
PostNewKey.admin_notices
train
public function admin_notices() { $afterKeyAdded = get_option( $this->option ); if ( empty( $afterKeyAdded ) ) { return; } switch( $afterKeyAdded ) { case 'success': echo '<div class="notice notice-success is-dismissible bglib-key-added"><p>' . esc_html( 'Your new BoldGrid Connect Key has been ...
php
{ "resource": "" }
q1418
PostNewKey.getCentralUrl
train
public static function getCentralUrl() { /** * Allow the return url to be filtered. * * The return url is the url that BoldGrid Central will link the user to after they received * their new BoldGrid Connect Key. * * By default, we will link them to Dashboard > Settings > BoldGrid Connect. However, ...
php
{ "resource": "" }
q1419
PostNewKey.processPost
train
public function processPost() { if ( $this->isPosting() ) { $releaseChannel = new ReleaseChannel; $key = new Key( $releaseChannel ); $hashed_key = md5( $_POST['activateKey'] ); $success = $key->addKey( $hashed_key ); /* * This option is used to setup an event similiar to WordPress' after_switch...
php
{ "resource": "" }
q1420
PostNewKey.isPosting
train
private function isPosting() { if ( empty( $_POST['activateKey'] ) ) { return false; } if ( empty( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'bglib-key-prompt') ) { return false; } if ( ! current_user_can( 'update_plugins' ) ) { return false; } return true; }
php
{ "resource": "" }
q1421
ResponseRest.setRestContent
train
public function setRestContent($data) { $serializer = $this->getSerializer(); if (isset($data)) { $this->setContent($serializer->serialize($data, $this->format)); } return $this; }
php
{ "resource": "" }
q1422
NameNode.create
train
public static function create($name) { $parts = explode('\\', $name); $name_node = new NameNode(); foreach ($parts as $i => $part) { $part = trim($part); if ($i > 0) { $name_node->append(Token::namespaceSeparator()); } if ($part !== '') { $name_node->append(Token::ide...
php
{ "resource": "" }
q1423
NameNode.getPathInfo
train
public function getPathInfo() { /** @var TokenNode $first */ $first = $this->firstChild(); $absolute = $first->getType() === T_NS_SEPARATOR; $relative = $first->getType() === T_NAMESPACE; $parts = $this->getParts(); return [ 'absolute' => $absolute, 'relative' => $relative, 'qu...
php
{ "resource": "" }
q1424
NameNode.getPath
train
public function getPath() { $path = ''; /** @var TokenNode $child */ $child = $this->head; while ($child) { $type = $child->getType(); if ($type === T_NAMESPACE || $type === T_NS_SEPARATOR || $type === T_STRING) { $path .= $child->getText(); } $child = $child->next; }...
php
{ "resource": "" }
q1425
NameNode.resolveUnqualified
train
protected function resolveUnqualified($name) { if ($this->parent instanceof NamespaceNode) { return '\\' . $name; } if ($this->parent instanceof UseDeclarationNode) { return '\\' . $name; } $namespace = $this->getNamespace(); $use_declarations = array(); if ($namespace) { $...
php
{ "resource": "" }
q1426
ReferenceAnalyzer.analyze
train
public function analyze(string $path) { $contents = (string) file_get_contents($path); $traverser = new NodeTraverser(); $traverser->addVisitor(new NameResolver()); $traverser->addVisitor($imports = new ImportVisitor()); $traverser->addVisitor($names = new NameVisitor()); ...
php
{ "resource": "" }
q1427
CommentNode.create
train
public static function create($comment) { $comment = trim($comment); $nl_count = substr_count($comment, "\n"); if ($nl_count > 1) { return LineCommentBlockNode::create($comment); } else { return new CommentNode(T_COMMENT, '// ' . $comment . "\n"); } }
php
{ "resource": "" }
q1428
ClientManager.getWebhookForClient
train
public function getWebhookForClient($name) { return Arr::get($this->clientsConfig[$name], 'webhook') ?: Arr::get($this->clientsDefaults, 'webhook'); }
php
{ "resource": "" }
q1429
ClientManager.getMessageDefaultsForClient
train
public function getMessageDefaultsForClient($name) { return array_merge( Arr::get($this->clientsDefaults, 'message_defaults', []), Arr::get($this->clientsConfig[$name], 'message_defaults', []) ); }
php
{ "resource": "" }
q1430
Mailer.sendRestorePassword
train
public function sendRestorePassword(string $email, string $hash): void { $mail = $this->createMail('restorePassword'); $mail->link = $this->link('Cms:Sign:restorePassword', [ 'hash' => $hash ]); $mail->setSubject('cms.mailing.restorePassword.subject') ->addTo($email); $mail->send(); }
php
{ "resource": "" }
q1431
Mailer.sendNewUser
train
public function sendNewUser(string $email, string $username, string $password): void { $mail = $this->createMail('newUser'); $mail->link = $this->link('Cms:Sign:in'); $mail->username = $username; $mail->password = $password; $mail->setSubject('cms.mailing.newUser.subject') ->addTo($email); $mail->sen...
php
{ "resource": "" }
q1432
State.toggleVisibility
train
public function toggleVisibility(StateToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $state = $event->getState(); $state ->setDispatcher($dispatcher) ->setVisible(!$state->getVisible()) ->save() ; $event->setSta...
php
{ "resource": "" }
q1433
StatementNode.getLineCount
train
public function getLineCount() { $count = 1; $this ->find(Filter::isInstanceOf('\Pharborist\WhitespaceNode')) ->each(function(WhitespaceNode $node) use (&$count) { $count += $node->getNewlineCount(); }); return $count; }
php
{ "resource": "" }
q1434
StatementNode.addCommentAbove
train
public function addCommentAbove($comment) { if ($comment instanceof LineCommentBlockNode) { $this->before($comment); } elseif (is_string($comment)) { $this->addCommentAbove(LineCommentBlockNode::create($comment)); } else { throw new \InvalidArgumentException(); } return $th...
php
{ "resource": "" }
q1435
ParameterNode.create
train
public static function create($parameter_name) { $parameter_name = '$' . ltrim($parameter_name, '$'); $parameter_node = new ParameterNode(); $parameter_node->addChild(new VariableNode(T_VARIABLE, $parameter_name), 'name'); return $parameter_node; }
php
{ "resource": "" }
q1436
ParameterNode.getDocBlockTag
train
public function getDocBlockTag() { $doc_comment = $this->getFunction()->getDocComment(); return $doc_comment ? $doc_comment->getParameter($this->name->getText()) : NULL; }
php
{ "resource": "" }
q1437
ParameterNode.hasDocTypes
train
public function hasDocTypes() { $doc_comment = $this->getFunction()->getDocComment(); if (!$doc_comment) { return FALSE; } $param_tag = $doc_comment->getParameter($this->getName()); if (!$param_tag) { return FALSE; } $types = $param_tag->getTypes(); return !empty($types); }
php
{ "resource": "" }
q1438
ParameterNode.getDocTypes
train
public function getDocTypes() { // No type specified means type is mixed. $types = ['mixed']; // Use types from the doc comment if available. $doc_comment = $this->getFunction()->getDocComment(); if (!$doc_comment) { return $types; } $param_tag = $doc_comment->getParameter($this->getNa...
php
{ "resource": "" }
q1439
ParameterNode.getTypes
train
public function getTypes() { // If type hint is set then that is the type of the parameter. if ($this->typeHint) { if ($this->typeHint instanceof TokenNode) { if ($this->typeHint->getType() === T_ARRAY) { $docTypes = $this->getDocTypes(); foreach ($docTypes as $docType) { ...
php
{ "resource": "" }
q1440
ContentController.addAdditionalFolderAction
train
public function addAdditionalFolderAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } $folder_id = \intval($this->getRequest()->request->get('additional_fold...
php
{ "resource": "" }
q1441
ContentController.removeAdditionalFolderAction
train
public function removeAdditionalFolderAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } $folder_id = \intval($this->getRequest()->request->get('additional_f...
php
{ "resource": "" }
q1442
TaxEngine.getDeliveryCountry
train
public function getDeliveryCountry() { if (null === $this->taxCountry) { /* is there a logged in customer ? */ /** @var Customer $customer */ if (null !== $customer = $this->getSession()->getCustomerUser()) { if (null !== $this->getSession()->getOrder() ...
php
{ "resource": "" }
q1443
CategoryController.setToggleVisibilityAction
train
public function setToggleVisibilityAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } $event = new CategoryToggleVisibilityEvent($this->getExistingObject());...
php
{ "resource": "" }
q1444
CategoryController.addRelatedPictureAction
train
public function addRelatedPictureAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } return $this->redirectToEditionTemplate(); }
php
{ "resource": "" }
q1445
DocProcessor.process
train
public static function process(array $docs) { return self::flatmap(function ($doc) { return self::flatmap(function ($tag) { return self::flatmap(function ($type) { return self::processType($type); }, self::processTag($tag)); }, $doc...
php
{ "resource": "" }
q1446
DocProcessor.processTag
train
private static function processTag(BaseTag $tag) { $types = []; if (method_exists($tag, 'getType') && is_callable([$tag, 'getType'])) { if (($type = $tag->getType()) !== null) { $types[] = $type; } } if (method_exists($tag, 'getArguments') &&...
php
{ "resource": "" }
q1447
DocProcessor.processType
train
private static function processType(Type $type) { // TODO type-resolver v1 compat // if ($type instanceof AbstractList) { if ($type instanceof Array_) { return self::flatmap(function ($t) { return self::processType($t); }, [$type->getKeyType(), $type->...
php
{ "resource": "" }
q1448
BaseLoop.initialize
train
protected function initialize() { $class = \get_class($this); if (null === self::$loopDefinitions) { self::$loopDefinitions = \array_flip($this->container->getParameter('thelia.parser.loops')); } if (isset(self::$loopDefinitions[$class])) { $this->loopName =...
php
{ "resource": "" }
q1449
BaseLoop.getDefaultArgs
train
protected function getDefaultArgs() { $defaultArgs = [ Argument::createBooleanTypeArgument('backend_context', false), Argument::createBooleanTypeArgument('force_return', false), Argument::createAnyTypeArgument('type'), Argument::createBooleanTypeArgument('no-c...
php
{ "resource": "" }
q1450
BaseLoop.initializeArgs
train
public function initializeArgs(array $nameValuePairs) { $faultActor = []; $faultDetails = []; if (null !== $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS)) { $event = new LoopExtendsInitializeArgsEvent($this, $nameValuePairs); $th...
php
{ "resource": "" }
q1451
BaseLoop.getArg
train
protected function getArg($argumentName) { $arg = $this->args->get($argumentName); if ($arg === null) { throw new \InvalidArgumentException( $this->translator->trans('Undefined loop argument "%name"', ['%name' => $argumentName]) ); } return $...
php
{ "resource": "" }
q1452
BaseLoop.getDispatchEventName
train
protected function getDispatchEventName($eventName) { $customEventName = TheliaEvents::getLoopExtendsEvent($eventName, $this->loopName); if (!isset(self::$dispatchCache[$customEventName])) { self::$dispatchCache[$customEventName] = $this->dispatcher->hasListeners($customEventName); ...
php
{ "resource": "" }
q1453
BaseLoop.extendsBuildModelCriteria
train
protected function extendsBuildModelCriteria(ModelCriteria $search = null) { if (null === $search) { return null; } $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA); if (null !== $eventName) { $this->dispatcher->dispat...
php
{ "resource": "" }
q1454
BaseLoop.extendsBuildArray
train
protected function extendsBuildArray(array $search = null) { if (null === $search) { return null; } $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_ARRAY); if (null !== $eventName) { $event = new LoopExtendsBuildArrayEvent($this, $se...
php
{ "resource": "" }
q1455
BaseLoop.extendsParseResults
train
protected function extendsParseResults(LoopResult $loopResult) { $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_PARSE_RESULTS); if (null !== $eventName) { $this->dispatcher->dispatch( $eventName, new LoopExtendsParseResultsEvent($this,...
php
{ "resource": "" }
q1456
Key.setNotice
train
public function setNotice( $forceDisplay = false ) { if ( $this->notice ) { return $this->notice; } // If we already have transient data saying the API is not available. if ( 0 === get_site_transient( 'boldgrid_available' ) ) { return new Notice( 'ConnectionIssue' ); } // If we don't have a key stor...
php
{ "resource": "" }
q1457
Key.addKey
train
public function addKey( $key ) { /* * @todo The majority of this method has been copied from * Boldgrid\Library\Library\Notice\KeyPrompt\addKey() because the logic to add a key should * be in this class and not the KeyPrompt class. that KeyPrompt method needs to be refactored. */ // When adding Keys, d...
php
{ "resource": "" }
q1458
Key.callCheckVersion
train
public function callCheckVersion( $args ) { if ( ! empty( $args['key'] ) ) { $call = new Api\Call( Configs::get( 'api' ) . '/api/plugin/checkVersion', $args ); // If there's an error set that as the response. if ( ! $response = $call->getError() ) { // If the response is successful, then retrieve the r...
php
{ "resource": "" }
q1459
Key.verify
train
public function verify( $key = null ) { $key = $key ? $key : Configs::get( 'key' ); // Make an API call for API data. $data = $this->callCheckVersion( array( 'key' => $key, 'channel' => $this->releaseChannel->getPluginChannel(), 'theme_channel' => $this->releaseChannel->getThemeChannel(), ) ); // L...
php
{ "resource": "" }
q1460
SendBearyChat.client
train
public function client($client) { $this->client = $client instanceof Client ? $client : bearychat($client); if ($this->message) { $this->message->setClient($this->client); } return $this; }
php
{ "resource": "" }
q1461
Image.createImagineInstance
train
protected function createImagineInstance() { $driver = ConfigQuery::read("imagine_graphic_driver", "gd"); switch ($driver) { case 'imagick': $image = new ImagickImagine(); break; case 'gmagick': $image = new GmagickImagine(); ...
php
{ "resource": "" }
q1462
BallouFactory.make
train
public function make(array $config) { Arr::requires($config, ['token']); $client = new Client(); return new BallouGateway($client, $config); }
php
{ "resource": "" }
q1463
ParentNode.childrenByInstance
train
protected function childrenByInstance($class_name) { $matches = []; $child = $this->head; while ($child) { if ($child instanceof $class_name) { $matches[] = $child; } $child = $child->next; } return $matches; }
php
{ "resource": "" }
q1464
ParentNode.prependChild
train
protected function prependChild(Node $node) { if ($this->head === NULL) { $this->childCount++; $node->parent = $this; $node->previous = NULL; $node->next = NULL; $this->head = $this->tail = $node; } else { $this->insertBeforeChild($this->head, $node); $this->head = ...
php
{ "resource": "" }
q1465
ParentNode.appendChild
train
protected function appendChild(Node $node) { if ($this->tail === NULL) { $this->prependChild($node); } else { $this->insertAfterChild($this->tail, $node); $this->tail = $node; } return $this; }
php
{ "resource": "" }
q1466
ParentNode.addChild
train
public function addChild(Node $node, $property_name = NULL) { $this->appendChild($node); if ($property_name !== NULL) { $this->{$property_name} = $node; } return $this; }
php
{ "resource": "" }
q1467
ParentNode.mergeNode
train
public function mergeNode(ParentNode $node) { $child = $node->head; while ($child) { $next = $child->next; $this->appendChild($child); $child = $next; } foreach ($node->getChildProperties() as $name => $value) { $this->{$name} = $value; } }
php
{ "resource": "" }
q1468
ParentNode.insertBeforeChild
train
protected function insertBeforeChild(Node $child, Node $node) { $this->childCount++; $node->parent = $this; if ($child->previous === NULL) { $this->head = $node; } else { $child->previous->next = $node; } $node->previous = $child->previous; $node->next = $child; $child->p...
php
{ "resource": "" }
q1469
ParentNode.insertAfterChild
train
protected function insertAfterChild(Node $child, Node $node) { $this->childCount++; $node->parent = $this; if ($child->next === NULL) { $this->tail = $node; } else { $child->next->previous = $node; } $node->previous = $child; $node->next = $child->next; $child->next = $no...
php
{ "resource": "" }
q1470
ParentNode.removeChild
train
protected function removeChild(Node $child) { $this->childCount--; foreach ($this->getChildProperties() as $name => $value) { if ($child === $value) { $this->{$name} = NULL; break; } } if ($child->previous === NULL) { $this->head = $child->next; } else { $...
php
{ "resource": "" }
q1471
ParentNode.replaceChild
train
protected function replaceChild(Node $child, Node $replacement) { foreach ($this->getChildProperties() as $name => $value) { if ($child === $value) { $this->{$name} = $replacement; break; } } $replacement->parent = $this; $replacement->previous = $child->previous; $replac...
php
{ "resource": "" }
q1472
ParentNode.getTree
train
public function getTree() { $children = array(); $properties = $this->getChildProperties(); $child = $this->head; $i = 0; while ($child) { $key = array_search($child, $properties, TRUE); if (!$key) { $key = $i; } if ($child instanceof ParentNode) { $children[$...
php
{ "resource": "" }
q1473
Environment.checkTypeAllowed
train
protected function checkTypeAllowed() { if (!in_array($this->type, static::$ALLOWED_TYPES)) { throw new \Exception( sprintf( "`%s` is not a valid environment type. Expected one of: %s", $this->type, implode(', ', static:...
php
{ "resource": "" }
q1474
ModuleHookCreationForm.verifyTemplates
train
public function verifyTemplates($value, ExecutionContextInterface $context) { $data = $context->getRoot()->getData(); if (!empty($data['templates']) && $data['method'] !== BaseHook::INJECT_TEMPLATE_METHOD_NAME) { $context->addViolation( $this->trans( ...
php
{ "resource": "" }
q1475
Operators.getI18n
train
public static function getI18n(Translator $translator, $operator) { $ret = $operator; switch ($operator) { case self::INFERIOR: $ret = $translator->trans( 'Less than', [] ); break; case se...
php
{ "resource": "" }
q1476
TheliaFormValidator.getErrorMessages
train
public function getErrorMessages(Form $form) { $errors = ''; foreach ($form->getErrors() as $key => $error) { $errors .= $error->getMessage().', '; } /** @var Form $child */ foreach ($form->all() as $child) { if (!$child->isValid()) { ...
php
{ "resource": "" }
q1477
AbstractSeoCrudController.getUpdateSeoEvent
train
protected function getUpdateSeoEvent($formData) { $updateSeoEvent = new UpdateSeoEvent($formData['id']); $updateSeoEvent ->setLocale($formData['locale']) ->setMetaTitle($formData['meta_title']) ->setMetaDescription($formData['meta_description']) ->set...
php
{ "resource": "" }
q1478
AbstractSeoCrudController.hydrateSeoForm
train
protected function hydrateSeoForm($object) { // The "SEO" tab form $locale = $object->getLocale(); $data = array( 'id' => $object->getId(), 'locale' => $locale, 'url' => $object->getRewrittenUrl($locale), 'm...
php
{ "resource": "" }
q1479
AbstractSeoCrudController.processUpdateSeoAction
train
public function processUpdateSeoAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) { return $response; } // Error (Default: false) $error_msg = false; ...
php
{ "resource": "" }
q1480
Module.checkDeactivation
train
private function checkDeactivation($module) { $moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir()); $modules = $moduleValidator->getModulesDependOf(); if (\count($modules) > 0) { $moduleList = implode(', ', array_column($modules, 'code')); $message...
php
{ "resource": "" }
q1481
Module.recursiveActivation
train
public function recursiveActivation(ModuleToggleActivationEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) { $moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir()); $dependenc...
php
{ "resource": "" }
q1482
Module.pay
train
public function pay(OrderPaymentEvent $event) { $order = $event->getOrder(); /* call pay method */ if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) { throw new \RuntimeException( Translator::getInstance()->trans( ...
php
{ "resource": "" }
q1483
MatchForTotalAmount.isMatching
train
public function isMatching() { $condition1 = $this->conditionValidator->variableOpComparison( $this->facade->getCartTotalTaxPrice(), $this->operators[self::CART_TOTAL], $this->values[self::CART_TOTAL] ); if ($condition1) { $condition2 = $this-...
php
{ "resource": "" }
q1484
FileUtil.findFiles
train
public static function findFiles($directory, $extensions = ['php']) { if (!is_dir($directory)) { return []; } $directory_iterator = new \RecursiveDirectoryIterator($directory); $iterator = new \RecursiveIteratorIterator($directory_iterator); $pattern = '/^.+\.(' . implode('|', $extensions) . '...
php
{ "resource": "" }
q1485
CheckDatabaseConnection.exec
train
public function exec() { $dsn = "mysql:host=%s;port=%s"; try { $this->connection = new \PDO( sprintf($dsn, $this->host, $this->port), $this->user, $this->password ); } catch (\PDOException $e) { $this->valid...
php
{ "resource": "" }
q1486
DocCommentTrait.getIndent
train
public function getIndent() { /** @var ParentNode $this */ $whitespace_token = $this->previousToken(); if (empty($whitespace_token) || $whitespace_token->getType() !== T_WHITESPACE) { return ''; } $nl = FormatterFactory::getDefaultFormatter()->getConfig('nl'); $lines = explode($nl, $whites...
php
{ "resource": "" }
q1487
Coupon.createOrUpdate
train
public function createOrUpdate( $code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultS...
php
{ "resource": "" }
q1488
Coupon.createOrUpdateConditions
train
public function createOrUpdateConditions($serializableConditions, $locale) { $this->setSerializedConditions($serializableConditions); // Set object language (i18n) if (!\is_null($locale)) { $this->setLocale($locale); } $this->save(); }
php
{ "resource": "" }
q1489
Coupon.setAmount
train
public function setAmount($amount) { $effects = $this->unserializeEffects($this->getSerializedEffects()); $effects['amount'] = \floatval($amount); $this->setEffects($effects); return $this; }
php
{ "resource": "" }
q1490
Coupon.getUsagesLeft
train
public function getUsagesLeft($customerId = null) { $usageLeft = $this->getMaxUsage(); if ($this->getPerCustomerUsageCount()) { // Get usage left for current customer. If the record is not found, // it means that the customer has not yes used this coupon. if (nul...
php
{ "resource": "" }
q1491
FileController.processImage
train
public function processImage( $fileBeingUploaded, $parentId, $parentType, $objectType, $validMimeTypes = array(), $extBlackList = array() ) { @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 2.6. Please use the p...
php
{ "resource": "" }
q1492
FileController.saveImageAjaxAction
train
public function saveImageAjaxAction($parentId, $parentType) { $config = FileConfiguration::getImageConfig(); return $this->saveFileAjaxAction( $parentId, $parentType, $config['objectType'], $config['validMimeTypes'], $config['extBlackList']...
php
{ "resource": "" }
q1493
FileController.saveDocumentAjaxAction
train
public function saveDocumentAjaxAction($parentId, $parentType) { $config = FileConfiguration::getDocumentConfig(); return $this->saveFileAjaxAction( $parentId, $parentType, $config['objectType'], $config['validMimeTypes'], $config['extBlack...
php
{ "resource": "" }
q1494
FileController.viewImageAction
train
public function viewImageAction($imageId, $parentType) { if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) { return $response; } $fileManager = $this->getFileManager(); $i...
php
{ "resource": "" }
q1495
FileController.viewDocumentAction
train
public function viewDocumentAction($documentId, $parentType) { if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) { return $response; } $fileManager = $this->getFileManager(); ...
php
{ "resource": "" }
q1496
FileController.updateImageAction
train
public function updateImageAction($imageId, $parentType) { if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) { return $response; } $imageInstance = $this->updateFileAction($image...
php
{ "resource": "" }
q1497
FileController.updateDocumentAction
train
public function updateDocumentAction($documentId, $parentType) { if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) { return $response; } $documentInstance = $this->updateFileActi...
php
{ "resource": "" }
q1498
FileController.deleteFileAction
train
public function deleteFileAction($fileId, $parentType, $objectType, $eventName) { $message = null; $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $fileManager = $this->getFi...
php
{ "resource": "" }
q1499
SlackGateway.formatMessage
train
public function formatMessage($string) { $string = str_replace('&', '&amp;', $string); $string = str_replace('<', '&lt;', $string); $string = str_replace('>', '&gt;', $string); return $string; }
php
{ "resource": "" }