_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3 values | text stringlengths 33 8k | 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 null");
}
$originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true);
if (! file_exists($originalDocumentPathInCache)) {
if (! file_exists($sourceFile)) {
throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile));
}
$mode = ConfigQuery::read(self::CONFIG_DELIVERY_MODE, 'symlink');
if ($mode == 'symlink') {
if (false === symlink($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir));
}
} else {
// mode = 'copy'
if | 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())
| 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->getDefaultTemplateId() == 0 ? null : $event->getDefaultTemplateId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
| 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();
try {
$fileList = ['images' => [], 'documentList' => []];
// Get category's files to delete after category deletion
$fileList['images']['list'] = CategoryImageQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
$fileList['documentList']['list'] = CategoryDocumentQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
// Delete category
$category
->setDispatcher($dispatcher)
->delete($con);
| php | {
"resource": ""
} |
q1404 | Category.toggleVisibility | train | public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$category = $event->getCategory();
| php | {
"resource": ""
} |
q1405 | Category.viewCheck | train | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'category') {
$category = CategoryQuery::create()
| php | {
"resource": ""
} |
q1406 | SiteController.renderToolSiteHeaderAction | train | public function renderToolSiteHeaderAction() {
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$melisKey = $this->params()->fromRoute('melisKey', '');
| 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->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$view | php | {
"resource": ""
} |
q1408 | SiteController.getSiteDomainPlatform | train | public function getSiteDomainPlatform()
{
$data = array();
if($this->getRequest()->isGet()){
$siteDomain = $this->getServiceLocator()->get('SiteDomain');
| 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_site_id', $siteId);
| 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();
$this->getEventManager()->trigger('meliscms_site_delete_by_id_start', $this, $eventDatas);
if($request->isPost()) {
$domainTable = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
$site404Table = $this->getServiceLocator()->get('MelisEngineTableSite404');
$siteID = (int) $request->getPost('siteid');
$siteEnv = $request->getPost('env');
$site404PageId = $request->getPost('site404Page');
$domainData = $domainTable->getDataBySiteIdAndEnv($siteID,$siteEnv);
$domainData = $domainData->current();
if($domainData)
{
$domainId = $domainData->sdom_id;
| 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(WhitespaceNode::create(' '));
$this->addChild(Token::_as());
$this->addChild(WhitespaceNode::create(' '));
$this->addChild($alias, 'alias');
| php | {
"resource": ""
} |
q1413 | UseDeclarationNode.getBoundedName | train | public function getBoundedName() {
if ($this->alias) {
return $this->alias->getText();
}
else {
| php | {
"resource": ""
} |
q1414 | Order.orderCartClear | train | public function orderCartClear(/** @noinspection PhpUnusedParameterInspection */ OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Empty cart and clear | 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 ($newStatus->getId() !== $order->getStatusId()) {
// We have to change the stock in the following cases :
// 1) The order is currently paid, and will become unpaid (get products back in stock unconditionnaly)
// 2) The order is currently unpaid, and will become paid (remove products from stock, except if was done at order creation $manageStockOnCreation == false)
// 3) The order is currently NOT PAID, and will become canceled or the like (get products back in stock if it was done at order creation $manageStockOnCreation == true)
// We consider the ManageStockOnCreation flag only if the order status as not yet changed.
// Count distinct order statuses (e.g. NOT_PAID to something else) in the order version table.
if (OrderVersionQuery::create()->groupByStatusId()->filterById($order->getId())->count() > 1) {
| 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 GetStockUpdateOperationOnOrderStatusChangeEvent($order, $newStatusModel);
$dispatcher->dispatch(
TheliaEvents::ORDER_GET_STOCK_UPDATE_OPERATION_ON_ORDER_STATUS_CHANGE,
$operationEvent
);
if ($operationEvent->getOperation() !== $operationEvent::DO_NOTHING) {
$orderProductList = $order->getOrderProducts();
/** @var OrderProduct $orderProduct */
foreach ($orderProductList as $orderProduct) {
$productSaleElementsId = $orderProduct->getProductSaleElementsId();
/** @var ProductSaleElements $productSaleElements */
if (null !== $productSaleElements = ProductSaleElementsQuery::create()->findPk($productSaleElementsId)) {
$offset = 0;
if ($operationEvent->getOperation() == $operationEvent::INCREASE_STOCK) {
$offset = $orderProduct->getQuantity();
| 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 successfully added!', 'boldgrid-library' ) .
'</p></div>';
break;
case 'fail':
echo | 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,
* with this filter plugins can change this url.
*
* @since 2.8.0
*
* @param string URL to the BoldGrid Connect settings page.
*/ | 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_theme hook.
* It allows us to take action on the page load following a new Connect Key being added.
*/
update_option( $this->option, $success ? 'success' | php | {
"resource": ""
} |
q1420 | PostNewKey.isPosting | train | private function isPosting() {
if ( empty( $_POST['activateKey'] ) ) {
return false;
}
if ( empty( $_GET['nonce'] ) | php | {
"resource": ""
} |
q1421 | ResponseRest.setRestContent | train | public function setRestContent($data)
{
$serializer = $this->getSerializer();
if (isset($data)) {
| 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());
}
| 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,
| 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 === | 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) {
$use_declarations = $namespace->getBody()->getUseDeclarations();
}
else {
/** @var \Pharborist\RootNode $root_node */
$root_node = $this->closest(Filter::isInstanceOf('\Pharborist\RootNode'));
if ($root_node) {
$use_declarations = $root_node->getUseDeclarations();
}
}
if ($this->parent instanceof FunctionCallNode) {
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isFunction() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
return $this->getParentPath() . $name;
}
elseif ($this->parent instanceof ConstantNode) { | 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());
| 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);
| php | {
"resource": ""
} |
q1428 | ClientManager.getWebhookForClient | train | public function getWebhookForClient($name)
{
return Arr::get($this->clientsConfig[$name], 'webhook') ?:
| php | {
"resource": ""
} |
q1429 | ClientManager.getMessageDefaultsForClient | train | public function getMessageDefaultsForClient($name)
{
return array_merge(
Arr::get($this->clientsDefaults, '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
]);
| 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;
| php | {
"resource": ""
} |
q1432 | State.toggleVisibility | train | public function toggleVisibility(StateToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$state = $event->getState();
$state
->setDispatcher($dispatcher)
| php | {
"resource": ""
} |
q1433 | StatementNode.getLineCount | train | public function getLineCount() {
$count = 1;
$this
->find(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))
->each(function(WhitespaceNode $node) use | php | {
"resource": ""
} |
q1434 | StatementNode.addCommentAbove | train | public function addCommentAbove($comment) {
if ($comment instanceof LineCommentBlockNode) {
$this->before($comment);
}
elseif (is_string($comment)) {
| php | {
"resource": ""
} |
q1435 | ParameterNode.create | train | public static function create($parameter_name) {
$parameter_name = '$' . ltrim($parameter_name, '$');
$parameter_node = new ParameterNode();
| php | {
"resource": ""
} |
q1436 | ParameterNode.getDocBlockTag | train | public function getDocBlockTag() {
$doc_comment = $this->getFunction()->getDocComment(); | 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) | 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->getName());
if (!$param_tag) {
| 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) {
if ($docType !== 'array' && substr($docType, -2) !== '[]') {
return [$this->typeHint->getText()];
}
}
| 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_folder_id'));
if ($folder_id > 0) {
$event = new ContentAddFolderEvent(
$this->getExistingObject(),
$folder_id
| 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_folder_id'));
if ($folder_id > 0) {
$event = new ContentRemoveFolderEvent(
$this->getExistingObject(),
$folder_id
| 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()
&& null !== $this->getSession()->getOrder()->getChoosenDeliveryAddress()
&& null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->getSession()->getOrder()->getChoosenDeliveryAddress())) {
| 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());
try {
$this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event);
| php | {
"resource": ""
} |
q1444 | CategoryController.addRelatedPictureAction | train | public function addRelatedPictureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
| 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) {
| 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->getValueType()]);
}
if ($type instanceof Compound) {
return self::flatmap(function ($t) {
return self::processType($t);
}, iterator_to_array($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 = self::$loopDefinitions[$class];
}
if (!isset(self::$loopDefinitionsArgs[$class])) {
| 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-cache', false),
Argument::createBooleanTypeArgument('return_url', true)
];
if (true === $this->countable) {
$defaultArgs[] = Argument::createIntTypeArgument('offset', 0);
$defaultArgs[] = Argument::createIntTypeArgument('page');
$defaultArgs[] = Argument::createIntTypeArgument('limit', PHP_INT_MAX);
}
if ($this instanceof SearchLoopInterface) {
$defaultArgs[] = Argument::createAnyTypeArgument('search_term');
$defaultArgs[] = new Argument(
'search_in',
new TypeCollection(
new EnumListType($this->getSearchIn())
)
);
| 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);
$this->dispatcher->dispatch($eventName, $event);
$nameValuePairs = $event->getLoopParameters();
}
$loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined";
$loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined";
$this->args->rewind();
while (($argument = $this->args->current()) !== false) {
$this->args->next();
$value = isset($nameValuePairs[$argument->name]) ? $nameValuePairs[$argument->name] : null;
/* check if mandatory */
if ($value === null && $argument->mandatory) {
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter is missing in loop type: %type, name: %name',
[
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
} elseif ($value === '') {
if (!$argument->empty) {
/* check if empty */
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter cannot be empty in loop type: %type, name: %name',
[
'%param' => $argument->name,
| php | {
"resource": ""
} |
q1451 | BaseLoop.getArg | train | protected function getArg($argumentName)
{
$arg = $this->args->get($argumentName);
if ($arg === null) {
throw new \InvalidArgumentException(
| php | {
"resource": ""
} |
q1452 | BaseLoop.getDispatchEventName | train | protected function getDispatchEventName($eventName)
{
$customEventName = TheliaEvents::getLoopExtendsEvent($eventName, $this->loopName);
if (!isset(self::$dispatchCache[$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->dispatch(
| 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);
| 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(
| 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' ) | 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 | 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 | 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(),
) );
// Let the transient data | php | {
"resource": ""
} |
q1460 | SendBearyChat.client | train | public function client($client)
{
$this->client = $client instanceof Client ? $client : bearychat($client);
if ($this->message) {
| php | {
"resource": ""
} |
q1461 | Image.createImagineInstance | train | protected function createImagineInstance()
{
$driver = ConfigQuery::read("imagine_graphic_driver", "gd");
switch ($driver) {
case 'imagick':
$image | php | {
"resource": ""
} |
q1462 | BallouFactory.make | train | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
| php | {
"resource": ""
} |
q1463 | ParentNode.childrenByInstance | train | protected function childrenByInstance($class_name) {
$matches = [];
$child = $this->head;
while ($child) {
if ($child instanceof $class_name) {
| php | {
"resource": ""
} |
q1464 | ParentNode.prependChild | train | protected function prependChild(Node $node) {
if ($this->head === NULL) {
$this->childCount++;
$node->parent = $this;
$node->previous = NULL; | php | {
"resource": ""
} |
q1465 | ParentNode.appendChild | train | protected function appendChild(Node $node) {
if ($this->tail === NULL) {
$this->prependChild($node);
| php | {
"resource": ""
} |
q1466 | ParentNode.addChild | train | public function addChild(Node $node, $property_name = NULL) {
$this->appendChild($node);
| php | {
"resource": ""
} |
q1467 | ParentNode.mergeNode | train | public function mergeNode(ParentNode $node) {
$child = $node->head;
while ($child) {
$next = $child->next;
$this->appendChild($child);
$child = $next;
| 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;
} | 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;
} | 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 {
$child->previous->next = $child->next;
| 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;
$replacement->next = $child->next;
if ($child->previous === NULL) {
$this->head = $replacement;
}
else | 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;
| 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",
| 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 self::INFERIOR_OR_EQUAL:
$ret = $translator->trans(
'Less than or equals',
[]
);
break;
case self::EQUAL:
$ret = $translator->trans(
'Equal to',
[]
);
| 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()) {
$fieldName = $child->getConfig()->getOption('label', null);
if (empty($fieldName)) {
| 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'])
| 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),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keywords' => $object->getMetaKeywords()
);
| 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;
// Create the Form from the request
$updateSeoForm = $this->getUpdateSeoForm($this->getRequest());
// Pass the object id to the request
$this->getRequest()->attributes->set($this->objectName . '_id', $this->getRequest()->get('current_id'));
try {
// Check the form against constraints violations
$form = $this->validateForm($updateSeoForm, "POST");
// Get the form field values
$data = $form->getData();
// Create a new event object with the modified fields
$updateSeoEvent = $this->getUpdateSeoEvent($data);
// Dispatch Update SEO Event
$this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);
// Execute additional Action
$response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);
if ($response == null) {
// If we have to stay on the same page, do not redirect to the successUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
return $this->redirectToEditionTemplate($this->getRequest());
}
// Redirect to the success URL
return $this->generateSuccessRedirect($updateSeoForm);
} else {
return $response;
}
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
/*} catch (\Exception $ex) {
| 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 = (\count($modules) == 1)
? Translator::getInstance()->trans(
'%s has dependency to module %s. You have to deactivate this module before.'
)
| 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());
$dependencies = $moduleValidator->getCurrentModuleDependencies();
foreach ($dependencies as $defMod) {
$submodule = ModuleQuery::create()
->findOneByCode($defMod["code"]);
| 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(
"Failed to find a payment Module with ID=%mid for order ID=%oid",
[
"%mid" => $order->getPaymentModuleId(),
"%oid" => $order->getId()
]
)
);
}
| 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->conditionValidator->variableOpComparison(
| 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) . ')$/i';
$regex | 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),
| 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 '';
}
| php | {
"resource": ""
} |
q1487 | Coupon.createOrUpdate | train | public function createOrUpdate(
$code,
$title,
array $effects,
$type,
$isRemovingPostage,
$shortDescription,
$description,
$isEnabled,
$expirationDate,
$isAvailableOnSpecialOffers,
$isCumulative,
$maxUsage,
$defaultSerializedRule,
$locale,
$freeShippingForCountries,
$freeShippingForMethods,
$perCustomerUsageCount,
$startDate = null
) {
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$this
->setCode($code)
->setType($type)
->setEffects($effects)
->setIsRemovingPostage($isRemovingPostage)
->setIsEnabled($isEnabled)
->setStartDate($startDate)
->setExpirationDate($expirationDate)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage)
| php | {
"resource": ""
} |
q1488 | Coupon.createOrUpdateConditions | train | public function createOrUpdateConditions($serializableConditions, $locale)
{
$this->setSerializedConditions($serializableConditions);
// Set object language (i18n)
| php | {
"resource": ""
} |
q1489 | Coupon.setAmount | train | public function setAmount($amount)
{
$effects = $this->unserializeEffects($this->getSerializedEffects());
$effects['amount'] | 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 (null !== $couponCustomerCount = CouponCustomerCountQuery::create()
->filterByCouponId($this->getId())
->filterByCustomerId($customerId)
| 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 process method | php | {
"resource": ""
} |
q1492 | FileController.saveImageAjaxAction | train | public function saveImageAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getImageConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
| php | {
"resource": ""
} |
q1493 | FileController.saveDocumentAjaxAction | train | public function saveDocumentAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getDocumentConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
| 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();
$imageModel = $fileManager->getModelInstance('image', $parentType);
$image = $imageModel->getQueryInstance()->findPk($imageId);
$redirectUrl = $image->getRedirectionUrl();
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
'redirectUrl' => $redirectUrl,
| 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();
$documentModel = $fileManager->getModelInstance('document', $parentType);
$document = $documentModel->getQueryInstance()->findPk($documentId);
$redirectUrl = $document->getRedirectionUrl();
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
'redirectUrl' => $redirectUrl,
| 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($imageId, $parentType, 'image', TheliaEvents::IMAGE_UPDATE);
if ($imageInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $imageInstance;
| 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->updateFileAction($documentId, $parentType, 'document', TheliaEvents::DOCUMENT_UPDATE);
if ($documentInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $documentInstance;
| 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->getFileManager();
$modelInstance = $fileManager->getModelInstance($objectType, $parentType);
$model = $modelInstance->getQueryInstance()->findPk($fileId);
if ($model == null) {
return $this->pageNotFound();
}
// Feed event
$fileDeleteEvent = new FileDeleteEvent($model);
// Dispatch Event to the Action
try {
$this->dispatch($eventName, $fileDeleteEvent);
$this->adminLogAppend(
$this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT),
AccessManager::UPDATE,
$this->getTranslator()->trans(
'Deleting %obj% for %id% with parent id %parentId%',
array(
'%obj%' => $objectType,
'%id%' => $fileDeleteEvent->getFileToDelete()->getId(),
'%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(),
)
),
$fileDeleteEvent->getFileToDelete()->getId()
);
} catch (\Exception $e) {
$message = $this->getTranslator()->trans(
'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)',
array(
'%obj%' => $objectType,
| php | {
"resource": ""
} |
q1499 | SlackGateway.formatMessage | train | public function formatMessage($string)
{
$string = str_replace('&', '&', $string);
$string = str_replace('<', '<', $string);
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.