_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2000 | BaseHook.getView | train | protected function getView()
{
$ret = "";
if (null !== $this->getRequest()) {
$ret = $this->getRequest()->attributes->get("_view", "");
}
return $ret;
} | php | {
"resource": ""
} |
q2001 | BaseHook.getCart | train | protected function getCart()
{
if (null === $this->cart) {
$this->cart = $this->getSession() ? $this->getSession()->getSessionCart($this->dispatcher) : null;
}
return $this->cart;
} | php | {
"resource": ""
} |
q2002 | BaseHook.getOrder | train | protected function getOrder()
{
if (null === $this->order) {
$this->order = $this->getSession() ? $this->getSession()->getOrder() : null;
}
return $this->order;
} | php | {
"resource": ""
} |
q2003 | BaseHook.getCurrency | train | protected function getCurrency()
{
if (null === $this->currency) {
$this->currency = $this->getSession() ? $this->getSession()->getCurrency(true) : Currency::getDefaultCurrency();
}
return $this->currency;
} | php | {
"resource": ""
} |
q2004 | BaseHook.getCustomer | train | protected function getCustomer()
{
if (null === $this->customer) {
$this->customer = $this->getSession() ? $this->getSession()->getCustomerUser() : null;
}
return $this->customer;
} | php | {
"resource": ""
} |
q2005 | BaseHook.getLang | train | protected function getLang()
{
if (null === $this->lang) {
$this->lang = $this->getSession() ? $this->getSession()->getLang(true) : $this->lang = Lang::getDefaultLanguage();
}
return $this->lang;
} | php | {
"resource": ""
} |
q2006 | BaseHook.addTemplate | train | public function addTemplate($hookCode, $value)
{
if (array_key_exists($hookCode, $this->templates)) {
throw new \InvalidArgumentException(sprintf("The hook '%s' is already used in this class.", $hookCode));
}
$this->templates[$hookCode] = $value;
} | php | {
"resource": ""
} |
q2007 | RegisterHookListenersPass.addHooksMethodCall | train | protected function addHooksMethodCall(ContainerBuilder $container, Definition $definition)
{
$moduleHooks = ModuleHookQuery::create()
->orderByHookId()
->orderByPosition()
->orderById()
->find();
$modulePosition = 0;
$hookId = 0;
/** @... | php | {
"resource": ""
} |
q2008 | RegisterHookListenersPass.getHookType | train | protected function getHookType($name)
{
$type = TemplateDefinition::FRONT_OFFICE;
if (null !== $name && \is_string($name)) {
$name = preg_replace("[^a-z]", "", strtolower(trim($name)));
if (\in_array($name, array('bo', 'back', 'backoffice'))) {
$type = Templa... | php | {
"resource": ""
} |
q2009 | RegisterHookListenersPass.isValidHookMethod | train | protected function isValidHookMethod($className, $methodName, $block, $failSafe = false)
{
try {
$method = new ReflectionMethod($className, $methodName);
$parameters = $method->getParameters();
$eventType = ($block) ?
HookDefinition::RENDER_BLOCK_EVENT :... | php | {
"resource": ""
} |
q2010 | BaseAction.genericUpdatePosition | train | protected function genericUpdatePosition(ModelCriteria $query, UpdatePositionEvent $event, EventDispatcherInterface $dispatcher = null)
{
if (null !== $object = $query->findPk($event->getObjectId())) {
if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) {
... | php | {
"resource": ""
} |
q2011 | BaseAction.genericUpdateSeo | train | protected function genericUpdateSeo(ModelCriteria $query, UpdateSeoEvent $event, EventDispatcherInterface $dispatcher = null)
{
if (null !== $object = $query->findPk($event->getObjectId())) {
$object
//for backward compatibility
->setDispatcher($dispatcher !== nul... | php | {
"resource": ""
} |
q2012 | BaseAction.genericToggleVisibility | train | public function genericToggleVisibility(ModelCriteria $query, ToggleVisibilityEvent $event, EventDispatcherInterface $dispatcher = null)
{
if (null !== $object = $query->findPk($event->getObjectId())) {
$newVisibility = !$object->getVisible();
$object
//for backward c... | php | {
"resource": ""
} |
q2013 | TemplateDescriptorValidator.schemaValidate | train | protected function schemaValidate(\DOMDocument $dom, \SplFileInfo $xsdFile)
{
$errorMessages = [];
try {
libxml_use_internal_errors(true);
if (!$dom->schemaValidate($xsdFile->getRealPath())) {
$errors = libxml_get_errors();
foreach ($errors ... | php | {
"resource": ""
} |
q2014 | ViewListener.onKernelView | train | public function onKernelView(GetResponseForControllerResultEvent $event)
{
$parser = $this->container->get('thelia.parser');
$templateHelper = $this->container->get('thelia.template_helper');
$parser->setTemplateDefinition($templateHelper->getActiveFrontTemplate(), true);
$request = ... | php | {
"resource": ""
} |
q2015 | NameVisitor.enterNode | train | public function enterNode(Node $node)
{
if ($node instanceof ConstFetch || $node instanceof FuncCall) {
$node->name = null;
}
if ($node instanceof FullyQualified) {
$this->names[] = $node->toString();
}
return $node;
} | php | {
"resource": ""
} |
q2016 | SingleInheritanceNode.getMethodNames | train | public function getMethodNames() {
return array_map(function (ClassMethodNode $node) {
return $node->getName()->getText();
}, $this->getMethods()->toArray());
} | php | {
"resource": ""
} |
q2017 | SingleInheritanceNode.getProperty | train | public function getProperty($name) {
$name = ltrim($name, '$');
$properties = $this
->getProperties()
->filter(function (ClassMemberNode $property) use ($name) {
return ltrim($property->getName(), '$') === $name;
});
return $properties->isEmpty() ? NULL : $properties[0];
} | php | {
"resource": ""
} |
q2018 | SingleInheritanceNode.createProperty | train | public function createProperty($name, ExpressionNode $value = NULL, $visibility = 'public') {
return $this->appendProperty(ClassMemberNode::create($name, $value, $visibility));
} | php | {
"resource": ""
} |
q2019 | SingleInheritanceNode.appendProperty | train | public function appendProperty($property) {
if (is_string($property)) {
$property = ClassMemberListNode::create($property);
}
$properties = $this->statements->children(Filter::isInstanceOf('\Pharborist\ClassMemberListNode'));
if ($properties->count() === 0) {
$this->statements->firstChild()-... | php | {
"resource": ""
} |
q2020 | DocCommentNode.create | train | public static function create($comment) {
$comment = trim($comment);
$lines = array_map('trim', explode("\n", $comment));
$text = "/**\n";
foreach ($lines as $i => $line) {
$text .= ' * ' . $line . "\n";
}
$text .= ' */';
return new DocCommentNode(T_DOC_COMMENT, $text);
} | php | {
"resource": ""
} |
q2021 | DocCommentNode.setIndent | train | public function setIndent($indent) {
$lines = explode("\n", $this->text);
if (count($lines) === 1) {
return $this;
}
$comment = '';
$last_index = count($lines) - 1;
foreach ($lines as $i => $line) {
if ($i === 0) {
$comment .= trim($line) . "\n";
}
elseif ($i === ... | php | {
"resource": ""
} |
q2022 | DocCommentNode.getDocBlock | train | public function getDocBlock() {
if ($this->docBlock === NULL) {
$namespace = '\\';
$aliases = array();
/** @var NamespaceNode $namespace_node */
$namespace_node = $this->closest(Filter::isInstanceOf('\Pharborist\Namespaces\NamespaceNode'));
if ($namespace_node !== NULL) {
$name... | php | {
"resource": ""
} |
q2023 | DocCommentNode.getParametersByName | train | public function getParametersByName() {
$param_tags = $this->getDocBlock()->getTagsByName('param');
$parameters = array();
/** @var \phpDocumentor\Reflection\DocBlock\Tag\ParamTag $param_tag */
foreach ($param_tags as $param_tag) {
$name = ltrim($param_tag->getVariableName(), '$');
$paramete... | php | {
"resource": ""
} |
q2024 | DocCommentNode.getParameter | train | public function getParameter($parameterName) {
$parameterName = ltrim($parameterName, '$');
$param_tags = $this->getDocBlock()->getTagsByName('param');
/** @var \phpDocumentor\Reflection\DocBlock\Tag\ParamTag $param_tag */
foreach ($param_tags as $param_tag) {
if (ltrim($param_tag->getVariableName... | php | {
"resource": ""
} |
q2025 | PagerdutyFactory.make | train | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new PagerdutyGateway($client, $config);
} | php | {
"resource": ""
} |
q2026 | LessHelper.fetch | train | public function fetch(array $options = [], array $modifyVars = [])
{
if (empty($options['overwrite'])) {
$options['overwrite'] = true;
}
$overwrite = $options['overwrite'];
unset($options['overwrite']);
$matches = $css = $less = [];
preg_match_all('@(<lin... | php | {
"resource": ""
} |
q2027 | LessHelper.less | train | public function less($less = 'styles.less', array $options = [], array $modifyVars = [])
{
$options = $this->setOptions($options);
$less = (array)$less;
if ($options['js']['env'] == 'development') {
return $this->jsBlock($less, $options);
}
try {
... | php | {
"resource": ""
} |
q2028 | LessHelper.jsBlock | train | protected function jsBlock($less, array $options = [])
{
$return = '';
$less = (array)$less;
// Append the user less files
foreach ($less as $les) {
$return .= $this->Html->meta('link', null, [
'link' => $les,
'rel' => 'stylesheet/less'... | php | {
"resource": ""
} |
q2029 | LessHelper.compile | train | protected function compile(array $input, $cache, array $options = [], array $modifyVars = [])
{
$parse = $this->prepareInputFilesForParsing($input);
if ($cache) {
$options += ['cache_dir' => $this->cssPath];
return \Less_Cache::Get($parse, $options, $modifyVars);
}
... | php | {
"resource": ""
} |
q2030 | LessHelper.prepareInputFilesForParsing | train | protected function prepareInputFilesForParsing(array $input = [])
{
$parse = [];
foreach ($input as $in) {
$less = realpath(WWW_ROOT . $in);
// If we have plugin notation (Plugin.less/file.less)
// ensure to properly load the files
list($plugin, $basef... | php | {
"resource": ""
} |
q2031 | LessHelper.setOptions | train | protected function setOptions(array $options)
{
// @codeCoverageIgnoreStart
$this->parserDefaults = array_merge($this->parserDefaults, [
// The import callback ensures that if a file is not found in the
// app's webroot, it will search for that file in its plugin's
... | php | {
"resource": ""
} |
q2032 | LessHelper.assetBaseUrl | train | protected function assetBaseUrl($plugin, $asset)
{
$dir = dirname($asset);
$path = !empty($dir) && $dir != '.' ? "/$dir" : null;
return $this->Url->assetUrl($plugin . $path);
} | php | {
"resource": ""
} |
q2033 | LessHelper.pluginAssetFile | train | protected function pluginAssetFile(array $url)
{
list($plugin, $basefile) = $url;
if ($plugin && Plugin::loaded($plugin)) {
return realpath(Plugin::path($plugin) . 'webroot' . DS . $basefile);
}
return false;
} | php | {
"resource": ""
} |
q2034 | LessHelper.assetSplit | train | protected function assetSplit($url)
{
$basefile = ltrim(ltrim($url, '.'), '/');
$exploded = explode('/', $basefile);
$plugin = Inflector::camelize(array_shift($exploded));
$basefile = implode(DS, $exploded);
return [
$plugin, $basefile
];
} | php | {
"resource": ""
} |
q2035 | PushoverFactory.make | train | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new PushoverGateway($client, $config);
} | php | {
"resource": ""
} |
q2036 | LoopResult.finalizeRows | train | public function finalizeRows()
{
// Fix rows LOOP_TOTAL if parseResults() did not added all resultsCollection items to the collection array
// see https://github.com/thelia/thelia/issues/2337
if (true === $this->countable && $this->getResultDataCollectionCount() !== $realCount = $this->getCo... | php | {
"resource": ""
} |
q2037 | MYR.parse | train | public static function parse(string $amount)
{
$parser = new DecimalMoneyParser(new ISOCurrencies());
return static::given(
$parser->parse($amount, new Currency('MYR'))->getAmount()
);
} | php | {
"resource": ""
} |
q2038 | AreaDeliveryModuleQuery.findByCountryAndModule | train | public function findByCountryAndModule(Country $country, Module $module, State $state = null)
{
$response = null;
$countryInAreaList = CountryAreaQuery::findByCountryAndState($country, $state);
/** @var CountryArea $countryInArea */
foreach ($countryInAreaList as $countryInArea) {
... | php | {
"resource": ""
} |
q2039 | PageEditionController.renderPagetabEditionAction | train | public function renderPagetabEditionAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$melisKey = $this->params()->fromRoute('melisKey', '');
/**
* Clearing the session data of the page in every open in page edition
*/
$c... | php | {
"resource": ""
} |
q2040 | PageEditionController.savePageSessionPluginAction | train | public function savePageSessionPluginAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$translator = $this->serviceLocator->get('translator');
$postValues = array();
$request = $this->getRequest();
if (!empty($idPage) &&... | php | {
"resource": ""
} |
q2041 | PageEditionController.removePageSessionPluginAction | train | public function removePageSessionPluginAction()
{
$module = $this->getRequest()->getQuery('module', null);
$pluginName = $this->getRequest()->getQuery('pluginName', '');
$pageId = $this->getRequest()->getQuery('pageId', null);
$pluginId = $this->getRequest()->getQuery('pluginId', nul... | php | {
"resource": ""
} |
q2042 | PageEditionController.getEditionLogOfPageEditionById | train | public function getEditionLogOfPageEditionById($pageId)
{
$data = array();
$pageEdition = $this->getServiceLocator()->get('MelisEnginePage');
$dataLogs = $pageEdition->getEditionLogsOfPage($pageId);
$data = $dataLogs;
return $data;
} | php | {
"resource": ""
} |
q2043 | PageEditionController.saveEditionAction | train | public function saveEditionAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$translator = $this->serviceLocator->get('translator');
$eventDatas = array('idPage' => $idPage);
$this->getEventManager()->trigger('meliscms_page_saveedition_start', null, $eventD... | php | {
"resource": ""
} |
q2044 | PageEditionController.getTinyTemplatesAction | train | public function getTinyTemplatesAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$success = 1;
$tinyTemplates = array();
// No pageId, return empty array
if (!empty($idPage))
{
// Get datas from page
$melisPage = $this->getServiceLocator()->get(... | php | {
"resource": ""
} |
q2045 | ObjectMethodCallNode.create | train | public static function create(Node $object, $method_name) {
/** @var ObjectMethodCallNode $node */
$node = new static();
$node->addChild($object, 'object');
$node->addChild(Token::objectOperator(), 'operator');
$node->addChild(Token::identifier($method_name), 'methodName');
$node->addChild(Token... | php | {
"resource": ""
} |
q2046 | XmlFileLoader.parseFilters | train | protected function parseFilters(SimpleXMLElement $xml)
{
if (false === $filters = $xml->xpath('//config:filters/config:filter')) {
return;
}
try {
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
} catch (ParameterNotFoundException $e) ... | php | {
"resource": ""
} |
q2047 | XmlFileLoader.parseTemplateDirectives | train | protected function parseTemplateDirectives(SimpleXMLElement $xml)
{
if (false === $baseParams = $xml->xpath('//config:templateDirectives/config:templateDirective')) {
return;
}
try {
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives")... | php | {
"resource": ""
} |
q2048 | XmlFileLoader.parseService | train | protected function parseService($id, $service, $file)
{
if ((string) $service['alias']) {
$public = true;
if (isset($service['public'])) {
$public = $this->getAttributeAsPhp($service, 'public');
}
$this->container->setAlias($id, new Alias((stri... | php | {
"resource": ""
} |
q2049 | XmlFileLoader.getArgumentsAsPhp | train | private function getArgumentsAsPhp(SimpleXMLElement $xml, $name, $lowercase = true)
{
$arguments = array();
foreach ($xml->$name as $arg) {
if (isset($arg['name'])) {
$arg['key'] = (string) $arg['name'];
}
$key = isset($arg['key']) ? (string) $arg[... | php | {
"resource": ""
} |
q2050 | Product.create | train | public function create(ProductCreateEvent $event)
{
$defaultTaxRuleId = null;
if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
$defaultTaxRuleId = $defaultTaxRule->getId();
}
$product = new ProductModel();
$product
-... | php | {
"resource": ""
} |
q2051 | Product.update | train | public function update(ProductUpdateEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$prevRef = $product->g... | php | {
"resource": ""
} |
q2052 | Product.delete | train | public function delete(ProductDeleteEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$fileList = ['images' ... | php | {
"resource": ""
} |
q2053 | Product.toggleVisibility | train | public function toggleVisibility(ProductToggleVisibilityEvent $event)
{
$product = $event->getProduct();
$product
->setDispatcher($this->eventDispatcher)
->setVisible($product->getVisible() ? false : true)
->save()
;
$event->setProduct($produ... | php | {
"resource": ""
} |
q2054 | Product.updateAccessoryPosition | train | public function updateAccessoryPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
return $this->genericUpdatePosition(AccessoryQuery::create(), $event, $dispatcher);
} | php | {
"resource": ""
} |
q2055 | Product.deleteFeatureProductValue | train | public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{
FeatureProductQuery::create()
->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId())
->delete()
;
} | php | {
"resource": ""
} |
q2056 | Product.deleteTemplateFeature | train | public function deleteTemplateFeature(TemplateDeleteFeatureEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed feature in all products which are using this template
$products = ProductQuery::create()
->filterByTemplateId($event->getTemplate()->getId())... | php | {
"resource": ""
} |
q2057 | Product.deleteTemplateAttribute | train | public function deleteTemplateAttribute(TemplateDeleteAttributeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed attribute in all products which are using this template
$pseToDelete = ProductSaleElementsQuery::create()
->useProductQuery()
... | php | {
"resource": ""
} |
q2058 | Product.viewCheck | train | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'product') {
$product = ProductQuery::create()
->filterById($event->getViewId())
->filterByVisible(1)
->count();
... | php | {
"resource": ""
} |
q2059 | CouponCreationForm.checkDuplicateCouponCode | train | public function checkDuplicateCouponCode($value, ExecutionContextInterface $context)
{
$exists = CouponQuery::create()->filterByCode($value)->count() > 0;
if ($exists) {
$context->addViolation(
Translator::getInstance()->trans(
"The coupon code '%code... | php | {
"resource": ""
} |
q2060 | CouponCreationForm.checkLocalizedDate | train | public function checkLocalizedDate($value, ExecutionContextInterface $context)
{
$format = LangQuery::create()->findOneByByDefault(true)->getDatetimeFormat();
if (false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(
Translator::getInstance()-... | php | {
"resource": ""
} |
q2061 | ModuleValidator.getModulesDependOf | train | public function getModulesDependOf($active = true)
{
$code = $this->getModuleDefinition()->getCode();
$query = ModuleQuery::create();
$dependantModules = [];
if (true === $active) {
$query->findByActivate(1);
} elseif (false === $active) {
$query->fin... | php | {
"resource": ""
} |
q2062 | ModuleValidator.getCurrentModuleDependencies | train | public function getCurrentModuleDependencies($recursive = false)
{
if (empty($this->moduleDescriptor->required)) {
return [];
}
$dependencies = [];
foreach ($this->moduleDescriptor->required->module as $dependency) {
$dependencyArray = [
"code... | php | {
"resource": ""
} |
q2063 | Node.sortKey | train | public function sortKey() {
if ($this instanceof RootNode) {
return spl_object_hash($this);
}
if (!$this->parent) {
return '~/' . spl_object_hash($this);
}
$path = $this->parent->sortKey() . '/';
$position = 0;
$previous = $this->previous;
while ($previous) {
$position+... | php | {
"resource": ""
} |
q2064 | Node.is | train | public function is($test) {
if (is_callable($test)) {
return (boolean) $test($this);
}
elseif (is_string($test)) {
return $this->is(Filter::isInstanceOf($test));
}
else {
throw new \InvalidArgumentException();
}
} | php | {
"resource": ""
} |
q2065 | Node.isAnyOf | train | public function isAnyOf(array $tests) {
foreach ($tests as $test) {
if ($this->is($test)) {
return TRUE;
}
}
return FALSE;
} | php | {
"resource": ""
} |
q2066 | Node.isAllOf | train | public function isAllOf(array $tests) {
foreach ($tests as $test) {
if (! $this->is($test)) {
return FALSE;
}
}
return TRUE;
} | php | {
"resource": ""
} |
q2067 | Node.fromValue | train | public static function fromValue($value) {
if (is_array($value)) {
$elements = [];
foreach ($value as $k => $v) {
$elements[] = ArrayPairNode::create(static::fromValue($k), static::fromValue($v));
}
return ArrayNode::create($elements);
}
elseif (is_string($value)) {
ret... | php | {
"resource": ""
} |
q2068 | Tlog.init | train | protected function init()
{
$this->setLevel(ConfigQuery::read(self::VAR_LEVEL, self::DEFAULT_LEVEL));
$this->dir_destinations = array(
__DIR__.DS.'Destination',
THELIA_LOCAL_DIR.'tlog'.DS.'destinations'
);
$this->setPrefix(ConfigQuery::read(self::VAR... | php | {
"resource": ""
} |
q2069 | ExportCommand.listExport | train | protected function listExport(OutputInterface $output)
{
$table = new Table($output);
foreach ((new ExportQuery)->find() as $export) {
$table->addRow([
$export->getRef(),
$export->getTitle(),
$export->getDescription()
]);
... | php | {
"resource": ""
} |
q2070 | ExportCommand.listSerializer | train | protected function listSerializer(OutputInterface $output)
{
$table = new Table($output);
/** @var SerializerManager $serializerManager */
$serializerManager = $this->getContainer()->get(RegisterSerializerPass::MANAGER_SERVICE_ID);
/** @var SerializerInterface $serializer */
... | php | {
"resource": ""
} |
q2071 | ExportCommand.listArchiver | train | protected function listArchiver(OutputInterface $output)
{
$table = new Table($output);
/** @var ArchiverManager $archiverManager */
$archiverManager = $this->getContainer()->get(RegisterArchiverPass::MANAGER_SERVICE_ID);
/** @var ArchiverInterface $archiver */
foreach ($ar... | php | {
"resource": ""
} |
q2072 | Session.getCurrency | train | public function getCurrency($forceDefault = true)
{
$currency = $this->get("thelia.current.currency");
if (null === $currency && $forceDefault) {
$currency = Currency::getDefaultCurrency();
}
return $currency;
} | php | {
"resource": ""
} |
q2073 | Session.setSessionCart | train | public function setSessionCart(Cart $cart = null)
{
if (null === $cart || $cart->isNew()) {
self::$transientCart = $cart;
$this->remove("thelia.cart_id");
} else {
self::$transientCart = null;
$this->set("thelia.cart_id", $cart->getId());
}
... | php | {
"resource": ""
} |
q2074 | Session.getSessionCart | train | public function getSessionCart(EventDispatcherInterface $dispatcher = null)
{
$cart_id = $this->get("thelia.cart_id", null);
if (null !== $cart_id) {
$cart = CartQuery::create()->findPk($cart_id);
} else {
$cart = self::$transientCart;
}
// If we do n... | php | {
"resource": ""
} |
q2075 | Session.clearSessionCart | train | public function clearSessionCart(EventDispatcherInterface $dispatcher)
{
$event = new CartCreateEvent();
$dispatcher->dispatch(TheliaEvents::CART_CREATE_NEW, $event);
if (null === $cart = $event->getCart()) {
throw new \LogicException(
"Unable to get a new empty... | php | {
"resource": ""
} |
q2076 | Session.isValidCart | train | protected function isValidCart(Cart $cart)
{
$customer = $this->getCustomerUser();
return (null !== $customer && $cart->getCustomerId() == $customer->getId())
||
(null === $customer && $cart->getCustomerId() === null);
} | php | {
"resource": ""
} |
q2077 | Coupon.create | train | public function create(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = new CouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | php | {
"resource": ""
} |
q2078 | Coupon.update | train | public function update(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = $event->getCouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | php | {
"resource": ""
} |
q2079 | Coupon.updateCondition | train | public function updateCondition(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$modelCoupon = $event->getCouponModel();
$this->createOrUpdateCondition($modelCoupon, $event, $dispatcher);
} | php | {
"resource": ""
} |
q2080 | Coupon.clearAllCoupons | train | public function clearAllCoupons(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Tell coupons to clear any data they may have stored
$this->couponManager->clear();
$this->getSession()->setConsumedCoupons(array());
$this->updateOrderDiscount($event, $eventName, $... | php | {
"resource": ""
} |
q2081 | Coupon.consume | train | public function consume(CouponConsumeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$totalDiscount = 0;
$isValid = false;
/** @var CouponInterface $coupon */
$coupon = $this->couponFactory->buildCouponFromCode($event->getCode());
if ($coupon) {
... | php | {
"resource": ""
} |
q2082 | Coupon.orderStatusChange | train | public function orderStatusChange(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// The order has been canceled or refunded ?
if ($event->getOrder()->isCancelled() || $event->getOrder()->isRefunded()) {
// Cancel usage of all coupons for this order
$us... | php | {
"resource": ""
} |
q2083 | Sale.updateProductSaleElementsPrices | train | protected function updateProductSaleElementsPrices($pseList, $promoStatus, $offsetType, Calculator $taxCalculator, $saleOffsetByCurrency, ConnectionInterface $con)
{
/** @var ProductSaleElements $pse */
foreach ($pseList as $pse) {
if ($pse->getPromo()!= $promoStatus) {
$... | php | {
"resource": ""
} |
q2084 | Sale.updateProductsSaleStatus | train | public function updateProductsSaleStatus(ProductSaleStatusUpdateEvent $event)
{
$taxCalculator = new Calculator();
$sale = $event->getSale();
// Get all selected product sale elements for this sale
if (null !== $saleProducts = SaleProductQuery::create()->filterBySale($sale)->orderB... | php | {
"resource": ""
} |
q2085 | Sale.create | train | public function create(SaleCreateEvent $event)
{
$sale = new SaleModel();
$sale
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setSaleLabel($event->getSaleLabel())
->save()
;
$event->setSale($sale);
} | php | {
"resource": ""
} |
q2086 | Sale.update | train | public function update(SaleUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$sale->setDispatcher($dispatcher);
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
... | php | {
"resource": ""
} |
q2087 | Sale.toggleActivity | train | public function toggleActivity(SaleToggleActivityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$sale = $event->getSale();
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$sale
->setDispatch... | php | {
"resource": ""
} |
q2088 | Sale.delete | train | public function delete(SaleDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
... | php | {
"resource": ""
} |
q2089 | Sale.clearStatus | train | public function clearStatus(/** @noinspection PhpUnusedParameterInspection */ SaleClearStatusEvent $event)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Set the active status of all Sales to false
SaleQuery::crea... | php | {
"resource": ""
} |
q2090 | Sale.checkSaleActivation | train | public function checkSaleActivation(SaleActiveStatusCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$now = time();
// Disable expired sales
... | php | {
"resource": ""
} |
q2091 | SchemaCombiner.combine | train | public function combine(array $schemaDocuments = [], array $externalSchemaDocuments = [])
{
$globalDatabaseElements = [];
// merge schema documents, per database
foreach ($schemaDocuments as $sourceSchemaDocument) {
if (!$sourceSchemaDocument instanceof \DOMDocument) {
... | php | {
"resource": ""
} |
q2092 | SchemaCombiner.inheritDatabaseAttributes | train | protected function inheritDatabaseAttributes(\DOMElement $databaseElement)
{
$attributesToInherit = [];
foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
if (!$databaseElement->hasAttribute($databaseAttribute)) {
continue;
... | php | {
"resource": ""
} |
q2093 | SchemaCombiner.applyDatabaseTablePrefix | train | protected function applyDatabaseTablePrefix(\DOMElement $databaseElement)
{
if (!$databaseElement->hasAttribute('tablePrefix')) {
return;
}
$tablePrefix = $databaseElement->getAttribute('tablePrefix');
/** @var \DOMElement $tableElement */
foreach ($databaseElem... | php | {
"resource": ""
} |
q2094 | SchemaCombiner.getDatabaseFromDatabaseElement | train | protected function getDatabaseFromDatabaseElement(\DOMElement $databaseElement)
{
$database = $databaseElement->getAttribute('name');
if (empty($database)) {
throw new \LogicException('Unnamed database node.');
}
return $database;
} | php | {
"resource": ""
} |
q2095 | SchemaCombiner.initGlobalDatabaseElement | train | protected function initGlobalDatabaseElement($database)
{
if (\in_array($database, $this->databases)) {
return;
}
$databaseDocument = new \DOMDocument(static::$GLOBAL_SCHEMA_XML_VERSION, static::$GLOBAL_SCHEMA_XML_ENCODING);
$databaseElement = $databaseDocument->createE... | php | {
"resource": ""
} |
q2096 | SchemaCombiner.mergeDatabaseElement | train | protected function mergeDatabaseElement(\DOMElement $sourceDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($sourceDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add a source ... | php | {
"resource": ""
} |
q2097 | SchemaCombiner.includeExternalSchema | train | protected function includeExternalSchema(\DOMElement $externalDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($externalDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add an i... | php | {
"resource": ""
} |
q2098 | ImportHandler.getImport | train | public function getImport($importId, $dispatchException = false)
{
$import = (new ImportQuery)->findPk($importId);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%id" in the ... | php | {
"resource": ""
} |
q2099 | ImportHandler.getImportByRef | train | public function getImportByRef($importRef, $dispatchException = false)
{
$import = (new ImportQuery)->findOneByRef($importRef);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id ... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.