_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q1700
OrderStatus.isPaid
train
public function isPaid($exact = true) { return $this->hasStatusHelper( $exact ? OrderStatus::CODE_PAID : [ OrderStatus::CODE_PAID, OrderStatus::CODE_PROCESSING, OrderStatus::CODE_SENT ] ); }
php
{ "resource": "" }
q1701
Availability.checkAvailability
train
private function checkAvailability() { // Get the boldgrid_available transient. $available = get_site_transient( 'boldgrid_available' ); // No transient was found. $wp_http = new WP_Http(); $url = $this->getUrl(); // Check that calling server is not blocked locally. if ( $wp_http->block_request( $url ) ...
php
{ "resource": "" }
q1702
TreeSitesController.getTreePagesByPageIdAction
train
public function getTreePagesByPageIdAction() { // Get the node id requested, or use default root -1 $idPage = $this->params()->fromQuery('nodeId', -1); $this->getEventManager()->trigger('melis_cms_tree_get_pages_start', $this, array('idPage' => $idPage)); if ($idPage == -1) $rootPages = $this->getRootForU...
php
{ "resource": "" }
q1703
TreeSitesController.getTreePagesForRightsManagementAction
train
public function getTreePagesForRightsManagementAction() { $idPage = $this->params()->fromQuery('nodeId', -1); if ($idPage == MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_root') $idPage = -1; else $idPage = str_replace(MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_', '', $idPage); $rootPages = ar...
php
{ "resource": "" }
q1704
TreeSitesController.cleanBreadcrumb
train
private function cleanBreadcrumb($breadcrumb) { $newArray = array(); if (!empty($breadcrumb)) foreach ($breadcrumb as $page) { if (!empty($page->tree_page_id)) array_push($newArray, $page->tree_page_id); } return $newArray; }
php
{ "resource": "" }
q1705
TreeSitesController.getRootForUser
train
private function getRootForUser() { $melisEngineTree = $this->serviceLocator->get('MelisEngineTree'); $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $melisCmsRights = $this->getServiceLocator()->get('MelisCmsRights'); // Get the rights of the user $xmlRights = $melisCoreAuth->getAuthRigh...
php
{ "resource": "" }
q1706
TreeSitesController.getPageIdBreadcrumbAction
train
public function getPageIdBreadcrumbAction() { $idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', '')); $idPage = ($idPage == 'root')? -1 : $idPage; $includeSelf = $this->params()->fromRoute('includeSelf', $this->params()->fromQuery('includeSelf', '')); ...
php
{ "resource": "" }
q1707
TreeSitesController.canEditPagesAction
train
public function canEditPagesAction() { $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $xmlRights = $melisCoreAuth->getAuthRights(); $rightsObj = simplexml_load_string($xmlRights); $sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES; if (empty($rightsObj...
php
{ "resource": "" }
q1708
CouponManager.getDiscount
train
public function getDiscount() { $discount = 0.00; $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) > 0) { $couponsKept = $this->sortCoupons($coupons); $discount = $this->getEffect($couponsKept); // Just In Case test $chec...
php
{ "resource": "" }
q1709
CouponManager.isCouponRemovingPostage
train
public function isCouponRemovingPostage(Order $order) { $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) == 0) { return false; } $couponsKept = $this->sortCoupons($coupons); /** @var CouponInterface $coupon */ foreach ($couponsKept as...
php
{ "resource": "" }
q1710
CouponManager.sortCoupons
train
protected function sortCoupons(array $coupons) { $couponsKept = array(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { if ($coupon && !$coupon->isExpired()) { if ($coupon->isCumulative()) { if (isset($couponsKept[0])) { ...
php
{ "resource": "" }
q1711
CouponManager.getEffect
train
protected function getEffect(array $coupons) { $discount = 0.00; /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $discount += $coupon->exec($this->facade); } return $discount; }
php
{ "resource": "" }
q1712
CouponManager.clear
train
public function clear() { $coupons = $this->facade->getCurrentCoupons(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $coupon->clear(); } }
php
{ "resource": "" }
q1713
CouponManager.decrementQuantity
train
public function decrementQuantity(Coupon $coupon, $customerId = null) { if ($coupon->isUsageUnlimited()) { return true; } else { try { $usageLeft = $coupon->getUsagesLeft($customerId); if ($usageLeft > 0) { // If the coupon...
php
{ "resource": "" }
q1714
AddressFormat.format
train
public function format( AddressInterface $address, $locale = null, $html = true, $htmlTag = "p", $htmlAttributes = [] ) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new Cou...
php
{ "resource": "" }
q1715
AddressFormat.postalLabelFormat
train
public function postalLabelFormat(AddressInterface $address, $locale = null, $originCountry = null, $options = []) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new CountryRepository(); $subdivisionReposit...
php
{ "resource": "" }
q1716
BaseController.getTranslator
train
public function getTranslator() { if (null === $this->translator) { $this->translator = $this->container->get('thelia.translator'); } return $this->translator; }
php
{ "resource": "" }
q1717
BaseController.retrieveFormBasedUrl
train
protected function retrieveFormBasedUrl($parameterName, BaseForm $form = null) { $url = null; if ($form != null) { $url = $form->getFormDefinedUrl($parameterName); } else { $url = $this->container->get('request_stack')->getCurrentRequest()->get($parameterName); ...
php
{ "resource": "" }
q1718
BaseController.getRoute
train
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL) { return $this->getRouteFromRouter( $this->getCurrentRouter(), $routeId, $parameters, $referenceType ); }
php
{ "resource": "" }
q1719
BaseController.getRouteFromRouter
train
protected function getRouteFromRouter( $routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL ) { /** @var Router $router */ $router = $this->getRouter($routerName); if ($router == null) { throw new \InvalidArgumentEx...
php
{ "resource": "" }
q1720
BaseController.checkXmlHttpRequest
train
protected function checkXmlHttpRequest() { if (false === $this->container->get('request_stack')->getCurrentRequest()->isXmlHttpRequest() && false === $this->isDebug()) { $this->accessDenied(); } }
php
{ "resource": "" }
q1721
TemplateController.performAdditionalDeleteAction
train
protected function performAdditionalDeleteAction($deleteEvent) { if ($deleteEvent->getProductCount() > 0) { $this->getParserContext()->setGeneralError( $this->getTranslator()->trans( "This template is in use in some of your products, and cannot be deleted. Del...
php
{ "resource": "" }
q1722
AdminLog.append
train
public static function append( $resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true, $resourceId = null ) { $log = new AdminLog(); $log ->setAdminLogin($adminUser !== null ? $a...
php
{ "resource": "" }
q1723
Formatter.spaceBefore
train
protected function spaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->setText(' '); } else { $node->before(Token::space()); } }
php
{ "resource": "" }
q1724
Formatter.spaceAfter
train
protected function spaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText(' '); } else { $node->after(Token::space()); } }
php
{ "resource": "" }
q1725
Formatter.removeSpaceBefore
train
protected function removeSpaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->remove(); } }
php
{ "resource": "" }
q1726
Formatter.removeSpaceAfter
train
protected function removeSpaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->remove(); } }
php
{ "resource": "" }
q1727
Formatter.newlineBefore
train
protected function newlineBefore(Node $node, $close = FALSE) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev_ws = $prev->previousToken(); if ($prev_ws instanceof CommentNode && $prev_ws->isLineComment() && $prev->getNewlineCount() === 0) { $prev->setText($this-...
php
{ "resource": "" }
q1728
Formatter.newlineAfter
train
protected function newlineAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText($this->getNewlineIndent($next)); } else { $node->after(Token::whitespace($this->getNewlineIndent())); } }
php
{ "resource": "" }
q1729
Formatter.handleBuiltinConstantNode
train
protected function handleBuiltinConstantNode(ConstantNode $node) { $to_upper = $this->config['boolean_null_upper']; if ($to_upper) { $node->toUpperCase(); } else { $node->toLowerCase(); } }
php
{ "resource": "" }
q1730
Formatter.encloseBlock
train
protected function encloseBlock($node) { if ($node && !($node instanceof StatementBlockNode)) { $blockNode = new StatementBlockNode(); $blockNode->append([Token::openBrace(), clone $node, Token::closeBrace()]); $node->replaceWith($blockNode); } }
php
{ "resource": "" }
q1731
Formatter.handleParens
train
protected function handleParens($node) { $open_paren = $node->getOpenParen(); $this->removeSpaceAfter($open_paren); $this->spaceBefore($open_paren); $close_paren = $node->getCloseParen(); $this->removeSpaceBefore($close_paren); }
php
{ "resource": "" }
q1732
Formatter.handleControlStructure
train
protected function handleControlStructure($node) { $this->handleParens($node); $colons = $node->children(Filter::isTokenType(':')); foreach ($colons as $colon) { $this->removeSpaceBefore($colon); } if ($colons->isNotEmpty()) { $this->newlineBefore($node->lastChild()->previous()); } ...
php
{ "resource": "" }
q1733
Formatter.isDeclaration
train
protected function isDeclaration(ParentNode $node) { return $node instanceof FunctionDeclarationNode || $node instanceof SingleInheritanceNode || $node instanceof InterfaceNode || $node instanceof ClassMethodNode || $node instanceof InterfaceMethodNode; }
php
{ "resource": "" }
q1734
Formatter.calculateColumnPosition
train
protected function calculateColumnPosition(Node $node) { // Add tokens until have whitespace containing newline. $column_position = 1; $start_token = $node instanceof ParentNode ? $node->firstToken() : $node; $token = $start_token; while ($token = $token->previousToken()) { if ($token instance...
php
{ "resource": "" }
q1735
CouponCreateOrUpdateEvent.setEffects
train
public function setEffects(array $effects) { // Amount is now optionnal. $this->amount = isset($effects['amount']) ? $effects['amount'] : 0; $this->effects = $effects; }
php
{ "resource": "" }
q1736
TopicEvent.toMessage
train
public function toMessage() { return array_merge($this->attributes, [ 'topic' => $this->topic, 'event' => $this->name, 'version' => $this->version, ]); }
php
{ "resource": "" }
q1737
TopicEvent.matches
train
public function matches($expr) { $params = self::parseEventExpr($expr); if ($params['topic'] === '*') { return true; } elseif ($this->topic !== $params['topic']) { return false; } if ($params['event'] === '*') { return true; } els...
php
{ "resource": "" }
q1738
OperatorFactory.createOperator
train
public static function createOperator($token_type, $static_only = FALSE) { if (array_key_exists($token_type, self::$operators)) { list($assoc, $precedence, $static, $binary_class_name, $unary_class_name) = self::$operators[$token_type]; if ($static_only && !$static) { return NULL; } ...
php
{ "resource": "" }
q1739
Plugin.getPluginFile
train
public static function getPluginFile( $slug ) { // Load plugin.php if not already included by core. if ( ! function_exists( 'get_plugins' ) ) { require ABSPATH . '/wp-admin/includes/plugin.php'; } $plugins = get_plugins(); foreach ( $plugins as $file => $info ) { // Get the basename of the plugin. ...
php
{ "resource": "" }
q1740
CouponFactory.buildCouponFromCode
train
public function buildCouponFromCode($couponCode) { /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); if ($couponModel === null) { return false; } // check if coupon is enabled if (!$couponModel->getIsEnabled()...
php
{ "resource": "" }
q1741
CouponFactory.buildCouponFromModel
train
public function buildCouponFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); if (!$this->container->has($model->getType())) { return false; } /**...
php
{ "resource": "" }
q1742
TwilioGateway.mapResponse
train
protected function mapResponse($success, array $response) { return (new Response())->setRaw($response)->map([ 'success' => $success, 'message' => $success ? 'Message sent' : $response['message'], ]); }
php
{ "resource": "" }
q1743
Api.setConfig
train
public function setConfig(array $config) { try { $this->config = $this ->getConfigResolver() ->resolve($config); } catch (ExceptionInterface $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } }
php
{ "resource": "" }
q1744
Api.createPaymentForm
train
public function createPaymentForm(array $data) { $this->ensureApiIsConfigured(); try { $data = $this ->getRequestOptionsResolver() ->resolve($data); } catch (ExceptionInterface $e) { throw new InvalidArgumentException($e->getMessage(),...
php
{ "resource": "" }
q1745
Api.checkPaymentResponse
train
public function checkPaymentResponse(array $data) { if (!isset($data['MAC'])) { return false; } $data = array_replace([ 'date' => null, 'montant' => null, 'reference' => null, 'texte-libre' => null, 'code-r...
php
{ "resource": "" }
q1746
Api.getMacKey
train
public function getMacKey() { $key = $this->config['key']; $hexStrKey = substr($key, 0, 38); $hexFinal = "" . substr($key, 38, 2) . "00"; $cca0 = ord($hexFinal); if ($cca0 > 70 && $cca0 < 97) { $hexStrKey .= chr($cca0 - 23) . substr($hexFinal, 1, 1); } ...
php
{ "resource": "" }
q1747
Api.htmlEncode
train
private function htmlEncode($data) { if (empty($data)) { return null; } $safeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-"; $result = ""; for ($i = 0; $i < strlen($data); $i++) { if (strstr($safeChars, $data[$i])) { ...
php
{ "resource": "" }
q1748
ArrayLookupNode.create
train
public static function create(ExpressionNode $array, ExpressionNode $key) { $node = new static(); /** @var Node $array */ $node->addChild($array, 'array'); $node->addChild(Token::openBracket()); /** @var Node $key */ $node->addChild($key, 'key'); $node->addChild(Token::closeBracket()); r...
php
{ "resource": "" }
q1749
ArrayLookupNode.getKey
train
public function getKey($index = 0) { $keys = $this->getKeys(); if (!is_integer($index)) { throw new \InvalidArgumentException(); } if ($index < 0 || $index >= count($keys)) { throw new \OutOfBoundsException(); } return $keys[$index]; }
php
{ "resource": "" }
q1750
AddClientAssets.addLocales
train
public function addLocales(ConfigureLocales $event) { foreach (new DirectoryIterator(__DIR__.'/../../locale') as $file) { if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) { $event->locales->addTranslations($file->getBasename('.'.$file->getExtension()), $fi...
php
{ "resource": "" }
q1751
ModuleInstallForm.checkModuleValidity
train
public function checkModuleValidity(UploadedFile $file, ExecutionContextInterface $context) { $modulePath = $this->unzipModule($file); if ($modulePath !== false) { try { // get the first directory $moduleFiles = $this->getDirContents($modulePath); ...
php
{ "resource": "" }
q1752
ModuleInstallForm.unzipModule
train
protected function unzipModule(UploadedFile $file) { $extractPath = false; $zip = new ZipArchiver(true); if (!$zip->open($file->getRealPath())) { throw new \Exception("unable to open zipfile"); } $extractPath = $this->tempdir(); if ($extractPath !== fals...
php
{ "resource": "" }
q1753
ModuleInstallForm.tempdir
train
protected function tempdir() { $tempfile = tempnam(sys_get_temp_dir(), ''); if (file_exists($tempfile)) { unlink($tempfile); } mkdir($tempfile); if (is_dir($tempfile)) { return $tempfile; } return false; }
php
{ "resource": "" }
q1754
FalseNode.create
train
public static function create($boolean = FALSE) { $is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper'); $node = new FalseNode(); $node->addChild(NameNode::create($is_upper ? 'FALSE' : 'false'), 'constantName'); return $node; }
php
{ "resource": "" }
q1755
CallNode.appendMethodCall
train
public function appendMethodCall($method_name) { $method_call = ObjectMethodCallNode::create(clone $this, $method_name); $this->replaceWith($method_call); return $method_call; }
php
{ "resource": "" }
q1756
Folder.countAllContents
train
public function countAllContents($contentVisibility = true) { $children = FolderQuery::findAllChild($this->getId()); array_push($children, $this); $query = ContentQuery::create()->filterByFolder(new ObjectCollection($children), Criteria::IN); if ($contentVisibility !== '*') { ...
php
{ "resource": "" }
q1757
Folder.getRoot
train
public function getRoot($folderId) { $folder = FolderQuery::create()->findPk($folderId); if (0 !== $folder->getParent()) { $parentFolder = FolderQuery::create()->findPk($folder->getParent()); if (null !== $parentFolder) { $folderId = $this->getRoot($parentFo...
php
{ "resource": "" }
q1758
PropelInitService.runCommand
train
public function runCommand(Command $command, array $parameters = [], OutputInterface $output = null) { $parameters['command'] = $command->getName(); $input = new ArrayInput($parameters); if ($output === null) { $output = new NullOutput(); } $command->setApplicat...
php
{ "resource": "" }
q1759
PropelInitService.buildPropelConfig
train
public function buildPropelConfig() { $propelConfigCache = new ConfigCache( $this->getPropelConfigFile(), $this->debug ); if ($propelConfigCache->isFresh()) { return; } $configService = new DatabaseConfigurationSource( Yaml::p...
php
{ "resource": "" }
q1760
PropelInitService.buildPropelInitFile
train
public function buildPropelInitFile() { $propelInitCache = new ConfigCache( $this->getPropelInitFile(), $this->debug ); if ($propelInitCache->isFresh()) { return; } $this->runCommand( new ConfigConvertCommand(), [ ...
php
{ "resource": "" }
q1761
PropelInitService.buildPropelModels
train
public function buildPropelModels() { $fs = new Filesystem(); // cache testing if ($fs->exists($this->getPropelModelDir() . 'hash') && file_get_contents($this->getPropelCacheDir() . 'hash') === file_get_contents($this->getPropelModelDir() . 'hash')) { return; ...
php
{ "resource": "" }
q1762
PropelInitService.registerPropelModelLoader
train
public function registerPropelModelLoader() { $loader = new ClassLoader(); $loader->addPrefix( '', // no prefix, models already define their full namespace $this->getPropelModelDir() ); $loader->register( true // prepend the autoloader to use cac...
php
{ "resource": "" }
q1763
PropelInitService.init
train
public function init($force = false) { $flockFactory = new Factory(new FlockStore()); $lock = $flockFactory->createLock('propel-cache-generation'); // Acquire a blocking cache generation lock $lock->acquire(true); try { if ($force) { (new Filesy...
php
{ "resource": "" }
q1764
ModuleExtension.addLoaderFile
train
protected function addLoaderFile(string $file, string $locale = null): void { if ($this->loader === null) { $builder = $this->getContainerBuilder(); $loader = $builder->getByType(LoaderFactory::class); $this->loader = $builder->getDefinition($loader); } $this->loader->addSetup('addFile', [$file, $local...
php
{ "resource": "" }
q1765
Load.setLoad
train
public function setLoad( $libraries ) { $load = false; $product = false; foreach( $libraries as $name => $version ) { // Check for branch versions normalized (dev/master). if ( strpos( $version, 'dev' ) !== false ) { $load = $version; $product = $name; break; } // Check for highest loade...
php
{ "resource": "" }
q1766
Load.setPath
train
public function setPath() { $found = $this->getLoad(); $path = false; if ( ! empty( $found->product ) ) { // Loading from must use plugin directory? if ( ! is_file( $path = trailingslashit( WPMU_PLUGIN_DIR ) . $found->product ) ) { // Loading from plugin directory? if ( ! is_file( $path = trailin...
php
{ "resource": "" }
q1767
Load.load
train
public function load( $loader ) { if ( ! empty( $this->configs['libraryDir'] ) ) { $library = $this->configs['libraryDir'] . 'src/Library'; // Only create a single instance of the BoldGrid Library Start. if ( did_action( 'Boldgrid\Library\Library\Start' ) === 0 ) { do_action( 'Boldgrid\Library\Library\S...
php
{ "resource": "" }
q1768
Locale.setDefault
train
public function setDefault(): void { $repo = $this->getRepository(); $locales = $repo->findAll(); foreach ($locales as $locale) { /* @var $locale self */ $locale->default = false; $repo->persist($locale); } $this->default = true; $repo->persist($this); $repo->flush(); }
php
{ "resource": "" }
q1769
PageDuplicationController.getOriginOfPageByPageIdAction
train
public function getOriginOfPageByPageIdAction() { $data = array(); $tool = $this->getServiceLocator()->get('MelisCmsPage'); $data = $tool->getOriginOfPage()->toArray(); return $data; }
php
{ "resource": "" }
q1770
AbstractAdminResourcesCompiler.process
train
public function process(\Symfony\Component\DependencyInjection\ContainerBuilder $container) { if (!$container->hasDefinition("thelia.admin.resources")) { return; } /** @var \Symfony\Component\DependencyInjection\Definition $adminResources */ $adminResources = $container-...
php
{ "resource": "" }
q1771
AbstractImport.checkMandatoryColumns
train
public function checkMandatoryColumns(array $data) { $diff = array_diff($this->mandatoryColumns, array_keys($data)); if (\count($diff) > 0) { throw new \UnexpectedValueException( Translator::getInstance()->trans( 'The following columns are missing: %c...
php
{ "resource": "" }
q1772
AbstractExport.applyOrderAndAliases
train
public function applyOrderAndAliases(array $data) { if ($this->orderAndAliases === null) { return $data; } $processedData = []; foreach ($this->orderAndAliases as $key => $value) { if (\is_integer($key)) { $fieldName = $value; ...
php
{ "resource": "" }
q1773
AbstractExport.beforeSerialize
train
public function beforeSerialize(array $data) { foreach ($data as $idx => &$value) { if ($value instanceof \DateTime) { $value = $value->format('Y-m-d H:i:s'); } } return $data; }
php
{ "resource": "" }
q1774
Filter.doFilter
train
private static function doFilter( $action, $class ) { $reflection = new \ReflectionClass( $class ); foreach ( $reflection->getMethods() as $method ) { if ( $method->isPublic() && ! $method->isConstructor() ) { $comment = $method->getDocComment(); // No hooks. if ( preg_match( '/@nohook[ \t\*\n]+/', ...
php
{ "resource": "" }
q1775
Filter.removeHook
train
public static function removeHook( $tag, $class, $name, $priority = 10 ) { global $wp_filter; // Check that filter exists. if ( isset( $wp_filter[ $tag ] ) ) { /** * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer * a simple array, and it is an object that ...
php
{ "resource": "" }
q1776
SaleModificationForm.checkDate
train
public function checkDate($value, ExecutionContextInterface $context) { $format = self::PHP_DATE_FORMAT; if (! empty($value) && false === \DateTime::createFromFormat($format, $value)) { $context->addViolation(Translator::getInstance()->trans("Date '%date' is invalid, please enter a vali...
php
{ "resource": "" }
q1777
ContainerAwareCommand.initRequest
train
protected function initRequest(Lang $lang = null) { $container = $this->getContainer(); $request = Request::create($this->getBaseUrl($lang)); $request->setSession(new Session(new MockArraySessionStorage())); $container->set("request_stack", new RequestStack()); $container->g...
php
{ "resource": "" }
q1778
Cart.duplicate
train
public function duplicate( $token, Customer $customer = null, Currency $currency = null, EventDispatcherInterface $dispatcher = null ) { if (!$dispatcher) { return false; } $cartItems = $this->getCartItems(); $cart = new Cart(); $...
php
{ "resource": "" }
q1779
Cart.getLastCartItemAdded
train
public function getLastCartItemAdded() { return CartItemQuery::create() ->filterByCartId($this->getId()) ->orderByCreatedAt(Criteria::DESC) ->findOne() ; }
php
{ "resource": "" }
q1780
Cart.getTotalVAT
train
public function getTotalVAT($taxCountry, $taxState = null) { return ($this->getTaxedAmount($taxCountry, true, $taxState) - $this->getTotalAmount(true)); }
php
{ "resource": "" }
q1781
Cart.getWeight
train
public function getWeight() { $weight = 0; foreach ($this->getCartItems() as $cartItem) { $itemWeight = $cartItem->getProductSaleElements()->getWeight(); $itemWeight *= $cartItem->getQuantity(); $weight += $itemWeight; } return $weight; }
php
{ "resource": "" }
q1782
Cart.isVirtual
train
public function isVirtual() { foreach ($this->getCartItems() as $cartItem) { if (0 < $cartItem->getProductSaleElements()->getWeight()) { return false; } $product = $cartItem->getProductSaleElements()->getProduct(); if (!$product->getVirtual())...
php
{ "resource": "" }
q1783
ConfigurationPresenter.createComponentConfigurationForm
train
protected function createComponentConfigurationForm(): Form { $form = $this->formFactory->create(); $form->setAjaxRequest(); $form->addGroup('cms.settings.basic'); $form->addImageUpload('cmsLogo', 'cms.settings.logo', 'cms.settings.deleteLogo') ->setNamespace('cms') ->setPreview('300x100'); $form->add...
php
{ "resource": "" }
q1784
Option.init
train
public static function init( $name = 'boldgrid_settings', $key = 'library' ) { self::$name = $name; self::$key = $key; self::$option = self::getOption(); }
php
{ "resource": "" }
q1785
Option.set
train
public static function set( $key, $value ) { self::$option[ self::$key ][ $key ] = $value; return update_option( self::$name, self::$option ); }
php
{ "resource": "" }
q1786
Option.delete
train
public static function delete( $key ) { unset( self::$option[ self::$key ][ $key ] ); return update_option( self::$name, self::$option ); }
php
{ "resource": "" }
q1787
Option.get
train
public static function get( $key = null, $default = array() ) { return $key && ! empty( self::$option[ $key ] ) ? self::$option[ $key ] : $default; }
php
{ "resource": "" }
q1788
SecurityContext.hasRequiredRole
train
final public function hasRequiredRole(UserInterface $user = null, array $roles = []) { if ($user != null) { // Check if user's roles matches required roles $userRoles = $user->getRoles(); foreach ($userRoles as $role) { if (\in_array($role, $roles)) { ...
php
{ "resource": "" }
q1789
SecurityContext.isGranted
train
final public function isGranted(array $roles, array $resources, array $modules, array $accesses) { // Find a user which matches the required roles. $user = $this->checkRole($roles); if (null === $user) { return false; } else { return $this->isUserGranted($rol...
php
{ "resource": "" }
q1790
SecurityContext.checkRole
train
public function checkRole(array $roles) { // Find a user which matches the required roles. $user = $this->getCustomerUser(); if (! $this->hasRequiredRole($user, $roles)) { $user = $this->getAdminUser(); if (! $this->hasRequiredRole($user, $roles)) { ...
php
{ "resource": "" }
q1791
MelisCmsPageEditionSavePluginSessionListener.insertOrReplaceTag
train
private function insertOrReplaceTag($content, $search, $replace) { $newContent = null; $regexSearch = "/(\<$search\>\<\!\[CDATA\[([0-9.])+\]\]\>\<\/$search\>)/"; if(preg_match($regexSearch, $content)) { $newContent = preg_replace($regexSearch, $replace, $content); } ...
php
{ "resource": "" }
q1792
MelisCmsPageEditionSavePluginSessionListener.updateMelisPlugin
train
private function updateMelisPlugin($pageId, $plugin, $pluginId, $content, $updateSettings = false) { $pluginContent = $content; $pluginSessionSettings = isset($_SESSION['meliscms']['content-pages'][$pageId]['private:melisPluginSettings'][$pluginId]) ? $_SESSION['meliscms']['cont...
php
{ "resource": "" }
q1793
MelisCmsPageEditionSavePluginSessionListener.setPluginWidthXmlAttribute
train
private function setPluginWidthXmlAttribute($pluginXml, $pluginSettings){ try { $pluginDesktop = isset($pluginSettings['width_desktop']) ? $pluginSettings['width_desktop'] : 100; $pluginTablet = isset($pluginSettings['width_tablet']) ? $pluginSettings['width_table...
php
{ "resource": "" }
q1794
Order.getWeight
train
public function getWeight() { $weight = 0; /* browse all products */ foreach ($this->getOrderProducts() as $orderProduct) { $weight += $orderProduct->getQuantity() * (double)$orderProduct->getWeight(); } return $weight; }
php
{ "resource": "" }
q1795
Order.getUntaxedPostage
train
public function getUntaxedPostage() { if (0 < $this->getPostageTax()) { $untaxedPostage = $this->getPostage() - $this->getPostageTax(); } else { $untaxedPostage = $this->getPostage(); } return $untaxedPostage; }
php
{ "resource": "" }
q1796
Order.hasVirtualProduct
train
public function hasVirtualProduct() { $virtualProductCount = OrderProductQuery::create() ->filterByOrderId($this->getId()) ->filterByVirtual(1, Criteria::EQUAL) ->count() ; return ($virtualProductCount !== 0); }
php
{ "resource": "" }
q1797
Order.setStatusHelper
train
public function setStatusHelper($statusCode) { if (null !== $ordeStatus = OrderStatusQuery::create()->findOneByCode($statusCode)) { $this->setOrderStatus($ordeStatus)->save(); } }
php
{ "resource": "" }
q1798
Order.getPaymentModuleInstance
train
public function getPaymentModuleInstance() { if (null === $paymentModule = ModuleQuery::create()->findPk($this->getPaymentModuleId())) { throw new TheliaProcessException("Payment module ID=" . $this->getPaymentModuleId() . " was not found."); } return $paymentModule->createInsta...
php
{ "resource": "" }
q1799
Order.getDeliveryModuleInstance
train
public function getDeliveryModuleInstance() { if (null === $deliveryModule = ModuleQuery::create()->findPk($this->getDeliveryModuleId())) { throw new TheliaProcessException("Delivery module ID=" . $this->getDeliveryModuleId() . " was not found."); } return $deliveryModule->creat...
php
{ "resource": "" }