_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q1500 | Config.create | train | public function create(ConfigCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$config = new ConfigModel();
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($event->getValue())
->setLocale($event->getLocale())... | php | {
"resource": ""
} |
q1501 | Config.setValue | train | public function setValue(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
if ($event->getValue() !== $config->getValue()) {
$config->setDispatcher($dispatcher)->setValue($e... | php | {
"resource": ""
} |
q1502 | Config.modify | train | public function modify(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($ev... | php | {
"resource": ""
} |
q1503 | Config.delete | train | public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
if (!$config->getSecured()) {
$config->setDispatcher($dispatcher)->delete();
$eve... | php | {
"resource": ""
} |
q1504 | StandardDescriptionFieldsTrait.addStandardDescFields | train | protected function addStandardDescFields($exclude = array())
{
if (! \in_array('locale', $exclude)) {
$this->formBuilder->add(
'locale',
'hidden',
[
'constraints' => [ new NotBlank() ],
'required' => true,... | php | {
"resource": ""
} |
q1505 | XMLSerializer.setDataNodeName | train | public function setDataNodeName($dataNodeName)
{
$this->dataNodeName = $dataNodeName;
$this->xmlEncoder->setRootNodeName($this->dataNodeName);
return $this;
} | php | {
"resource": ""
} |
q1506 | RequestListener.registerPreviousUrl | train | public function registerPreviousUrl(PostResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->isXmlHttpRequest() && $event->getResponse()->isSuccessful()) {
$referrer = $request->attributes->get('_previous_url', null);
$catalogViews = ['category', 'produc... | php | {
"resource": ""
} |
q1507 | WebhookFactory.make | train | public function make(array $config)
{
Arr::requires($config, ['endpoint']);
$client = new Client();
return new WebhookGateway($client, $config);
} | php | {
"resource": ""
} |
q1508 | TrueNode.create | train | public static function create($boolean = TRUE) {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new TrueNode();
$node->addChild(NameNode::create($is_upper ? 'TRUE' : 'true'), 'constantName');
return $node;
} | php | {
"resource": ""
} |
q1509 | NullNode.create | train | public static function create($name = 'null') {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new NullNode();
$node->addChild(NameNode::create($is_upper ? 'NULL' : 'null'), 'constantName');
return $node;
} | php | {
"resource": ""
} |
q1510 | Delivery.getPostage | train | public function getPostage(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$module = $event->getModule();
// dispatch event to target specific module
$dispatcher->dispatch(
TheliaEvents::getModuleEvent(
TheliaEvents::MODULE_DELIVE... | php | {
"resource": ""
} |
q1511 | AbstractPresenter.addBreadcrumbLink | train | public function addBreadcrumbLink(string $name, string $link = null, array $arguments = []): Link
{
return $this['breadcrumb']->addLink($name, $link, $arguments);
} | php | {
"resource": ""
} |
q1512 | AbstractPresenter.viewMobileMenu | train | public function viewMobileMenu(bool $view = true): void
{
$this->template->shifted = $view;
$this['dockbar']->setShifted($view);
} | php | {
"resource": ""
} |
q1513 | AreaController.addCountry | train | public function addCountry()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaCountryForm = $this->createForm(AdminForm::AREA_COUNTRY);
$error_msg = nu... | php | {
"resource": ""
} |
q1514 | AreaController.removeCountries | train | public function removeCountries()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaDeleteCountriesForm = $this->createForm(AdminForm::AREA_DELETE_COUNTRY);
... | php | {
"resource": ""
} |
q1515 | AsseticAssetManager.getStamp | train | protected function getStamp($directory)
{
$stamp = '';
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($iterator as $file) {
... | php | {
"resource": ""
} |
q1516 | AsseticAssetManager.copyAssets | train | protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
{
Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator... | php | {
"resource": ""
} |
q1517 | AsseticAssetManager.prepareAssets | train | public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
{
// Compute the absolute path of the output directory
$to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
// Get a path ... | php | {
"resource": ""
} |
q1518 | AsseticAssetManager.decodeAsseticFilters | train | protected function decodeAsseticFilters(FilterManager $filterManager, $filters)
{
if (! empty($filters)) {
$filter_list = \is_array($filters) ? $filters : explode(',', $filters);
foreach ($filter_list as $filter_name) {
$filter_name = trim($filter_name);
... | php | {
"resource": ""
} |
q1519 | SaleController.toggleActivity | train | public function toggleActivity()
{
if (null !== $response = $this->checkAuth(AdminResources::SALES, [], AccessManager::UPDATE)) {
return $response;
}
try {
$this->dispatch(
TheliaEvents::SALE_TOGGLE_ACTIVITY,
new SaleToggleActivityEven... | php | {
"resource": ""
} |
q1520 | BladeRenderer.render | train | public function render(string $template, array $data = []): string
{
$data = array_merge($this->data, $data);
return $this->getRenderer()->make($template, $data)->render();
} | php | {
"resource": ""
} |
q1521 | FreeProduct.getRelatedCartItem | train | protected function getRelatedCartItem($product)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (isset($cartItemIdList[$product->getId()])) {
$cartItemId = $cartItemIdList[$product->getId()];
... | php | {
"resource": ""
} |
q1522 | FreeProduct.setRelatedCartItem | train | protected function setRelatedCartItem($product, $cartItemId)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (! \is_array($cartItemIdList)) {
$cartItemIdList = array();
}
$cart... | php | {
"resource": ""
} |
q1523 | LineCommentBlockNode.create | train | public static function create($comment) {
$block_comment = new LineCommentBlockNode();
$comment = trim($comment);
$lines = array_map('rtrim', explode("\n", $comment));
foreach ($lines as $line) {
$comment_node = new CommentNode(T_COMMENT, '// ' . $line . "\n");
$block_comment->addChild($comm... | php | {
"resource": ""
} |
q1524 | LineCommentBlockNode.addIndent | train | public function addIndent($whitespace) {
$has_indent = $this->children(function (Node $node) {
return !($node instanceof CommentNode);
})->count() > 0;
if ($has_indent) {
$this->children(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))->each(function (WhitespaceNode $ws_node) use ($whitespace... | php | {
"resource": ""
} |
q1525 | SimpleEvent.setAttribute | train | public function setAttribute($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->attributes[$k] = $v;
}
} else {
$this->attributes[$name] = $value;
}
} | php | {
"resource": ""
} |
q1526 | NumberFormat.formatStandardNumber | train | public function formatStandardNumber($number, $decimals = null)
{
$lang = $this->request->getSession()->getLang();
if ($decimals === null) {
$decimals = $lang->getDecimals();
}
return number_format($number, $decimals, '.', '');
} | php | {
"resource": ""
} |
q1527 | Plugin.getFiltered | train | public static function getFiltered( $pattern = '' ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if ( empty( $pattern ) ) {
return $plugins;
}
$filtered = array();
foreach ( $plugins as $slug => $data ) {
if (... | php | {
"resource": ""
} |
q1528 | Plugin.isBoldgridPlugin | train | public static function isBoldgridPlugin( $plugin ) {
if( empty( $plugin ) ) {
return false;
}
$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();
$plugins = \Boldgrid\Library\Library\Util\Plugin::getFiltered( $pluginChecker->getPluginPattern() );
return array_key_exists( $plugin, $plugins )... | php | {
"resource": ""
} |
q1529 | LanguageController.getTranslationsList | train | public function getTranslationsList()
{
$data = "";
$melisCmsAuth = $this->getServiceLocator()->get('MelisCoreAuth');
$melisCmsRights = $this->getServiceLocator()->get('MelisCoreRights');
return $data;
} | php | {
"resource": ""
} |
q1530 | LanguageController.getDataTableTranslationsAction | train | public function getDataTableTranslationsAction()
{
// Get the current language
$container = new Container('meliscms');
$locale = $container['melis-lang-locale'];
$translator = $this->getServiceLocator()->get('translator');
$transData = array(
'sEmptyTabl... | php | {
"resource": ""
} |
q1531 | TaxRule.getArrayFromJson22Compat | train | protected function getArrayFromJson22Compat($obj)
{
$obj = $this->getArrayFromJson($obj);
if (isset($obj[0]) && ! \is_array($obj[0])) {
$objEx = [];
foreach ($obj as $item) {
$objEx[] = [$item, 0];
}
return $objEx;
}
... | php | {
"resource": ""
} |
q1532 | ExampleController.handleAction | train | private function handleAction(Request $request, &$data) {
// Keyword Search
if ($this->isAction($request, "searchByKeyword")) {
$preparedKeywords = htmlspecialchars($data["keywords"]);
$data["listings"] = $this->listingController($data)
->setSortBy($data["sort... | php | {
"resource": ""
} |
q1533 | ExampleController.getPageData | train | private function getPageData(Request $request) {
$publicDMQL = '(L_UpdateDate=' . date('Y-m-d', (strtotime('-1 day', time()))) . '-' . date('Y-m-d') . ')';
$data = [
"isPublic" => ExampleController::IS_PUBLIC,
"disableCache" => !empty($request->disableCache),
"keywo... | php | {
"resource": ""
} |
q1534 | Product.countSaleElements | train | public function countSaleElements($con = null)
{
return ProductSaleElementsQuery::create()->filterByProductId($this->id)->count($con);
} | php | {
"resource": ""
} |
q1535 | Product.setDefaultCategory | train | public function setDefaultCategory($defaultCategoryId)
{
// Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)
if ($defaultCategoryId <= 0) {
$defaultCategoryId = null;
}
/** @var ProductCategory $productCategory */
$productCate... | php | {
"resource": ""
} |
q1536 | Product.create | train | public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight, $baseQuantity = 0)
{
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this... | php | {
"resource": ""
} |
q1537 | Product.createProductSaleElement | train | public function createProductSaleElement(ConnectionInterface $con, $weight, $basePrice, $salePrice, $currencyId, $isDefault, $isPromo = false, $isNew = false, $quantity = 0, $eanCode = '', $ref = false)
{
// Create an empty product sale element
$saleElements = new ProductSaleElements();
$sa... | php | {
"resource": ""
} |
q1538 | Product.addCriteriaToPositionQuery | train | protected function addCriteriaToPositionQuery($query)
{
// Find products in the same category
$products = ProductCategoryQuery::create()
->filterByCategoryId($this->getDefaultCategoryId())
->filterByDefaultCategory(true)
->select('product_id')
->find()... | php | {
"resource": ""
} |
q1539 | MelisCmsPageGetterService.getPageContent | train | public function getPageContent($pageId)
{
// Retrieve cache version if front mode to avoid multiple calls
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$pageContent = $melisEngineCacheSystem->getCacheByKey($this->cachekey.$pageId, $this->cacheConfig, tr... | php | {
"resource": ""
} |
q1540 | Validate.setHash | train | public function setHash( $key = null ) {
$key = $key ? $this->sanitizeKey( $key ) : $this->getKey();
return $this->hash = $this->hashKey( $key );
} | php | {
"resource": ""
} |
q1541 | Validate.sanitizeKey | train | public function sanitizeKey( $key ) {
$key = trim( strtolower( preg_replace( '/-/', '', $key ) ) );
$key = implode( '-', str_split( $key, 8 ) );
return sanitize_key( $key );
} | php | {
"resource": ""
} |
q1542 | Validate.isValid | train | public function isValid( $key = null ) {
$key = $key ? $this->sanitizeKey( $key ) : $this->getKey();
return strlen( $key ) === 35;
} | php | {
"resource": ""
} |
q1543 | PageSeoController.getSeoKeywordsByPageId | train | public function getSeoKeywordsByPageId($pageId)
{
$pageId = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$data = array();
$seoKeywords = $pageId->getSeoKeywords($pageId);
$data = $seoKeywords;
return $data;
} | php | {
"resource": ""
} |
q1544 | PageSeoController.cleanURL | train | private function cleanURL(string $url = '')
{
$url = str_replace(' ', '-', $url); // Replaces all spaces with hyphens
$url = preg_replace('/[^A-Za-z0-9\/\-]+/', '-', $url); // Replaces special characters with hyphens
// remove "/" prefix on generated URL
if (substr($url, 0, 1) =... | php | {
"resource": ""
} |
q1545 | Reseller.getAttribute | train | public function getAttribute( $attribute ) {
$data = $this->getData();
return ! empty ( $data[$attribute] ) ? $data[$attribute] : '';
} | php | {
"resource": ""
} |
q1546 | Reseller.getData | train | public function getData() {
$data = $this->resellerOption;
$data['reseller_identifier'] = ! empty( $data['reseller_identifier'] ) ?
strtolower( $data['reseller_identifier'] ) : null;
$data['reseller_website_url'] = ! empty( $data['reseller_website_url'] ) ?
esc_url( $data['reseller_website_url'] ) : 'http... | php | {
"resource": ""
} |
q1547 | Reseller.getMenuItems | train | protected function getMenuItems() {
$data = $this->getData();
return array(
'topLevel' => array(
'id' => 'reseller-adminbar-icon',
'title' => '<span aria-hidden="true" class="' . $data['reseller_identifier'] .
'-icon ab-icon"></span>',
'href' => $data['reseller_website_url'],
'meta' => arra... | php | {
"resource": ""
} |
q1548 | FeatureController.addRemoveFromAllTemplates | train | protected function addRemoveFromAllTemplates($eventType)
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
try {
if (null !== $object = $this->getExistin... | php | {
"resource": ""
} |
q1549 | TreePickerManipulatingListener.manipulateTreePrickerForSortOrder | train | public function manipulateTreePrickerForSortOrder(ManipulateWidgetEvent $event)
{
$widget = $event->getWidget();
if (!($widget instanceof TreePicker)) {
return;
}
$options = (array) $widget->options;
if (0 === \count($options)) {
return;
}
... | php | {
"resource": ""
} |
q1550 | BasePresenter.ajaxRedirect | train | public function ajaxRedirect(string $destination, array $args = []): void
{
$this->payload->forceRedirect = $this->link($destination, $args);
$this->sendPayload();
} | php | {
"resource": ""
} |
q1551 | ConditionFactory.serializeConditionCollection | train | public function serializeConditionCollection(ConditionCollection $collection)
{
if ($collection->count() == 0) {
/** @var ConditionInterface $conditionNone */
$conditionNone = $this->container->get(
'thelia.condition.match_for_everyone'
);
$col... | php | {
"resource": ""
} |
q1552 | ConditionFactory.unserializeConditionCollection | train | public function unserializeConditionCollection($serializedConditions)
{
$unserializedConditions = json_decode(base64_decode($serializedConditions));
$collection = new ConditionCollection();
if (!empty($unserializedConditions)) {
/** @var SerializableCondition $condition */
... | php | {
"resource": ""
} |
q1553 | ConditionFactory.build | train | public function build($conditionServiceId, array $operators, array $values)
{
if (!$this->container->has($conditionServiceId)) {
return false;
}
/** @var ConditionInterface $condition */
$condition = $this->container->get($conditionServiceId);
$condition->setVali... | php | {
"resource": ""
} |
q1554 | ConditionFactory.getInputsFromServiceId | train | public function getInputsFromServiceId($conditionServiceId)
{
if (!$this->container->has($conditionServiceId)) {
return false;
}
/** @var ConditionInterface $condition */
$condition = $this->container->get($conditionServiceId);
return $this->getInputsFromConditi... | php | {
"resource": ""
} |
q1555 | ModuleConfigQuery.getConfigValue | train | public function getConfigValue($moduleId, $variableName, $defaultValue = null, $valueLocale = null)
{
$value = null;
$configValue = self::create()
->filterByModuleId($moduleId)
->filterByName($variableName)
->findOne();
;
if (null !== $configValu... | php | {
"resource": ""
} |
q1556 | ModuleConfigQuery.setConfigValue | train | public function setConfigValue($moduleId, $variableName, $variableValue, $valueLocale = null, $createIfNotExists = true)
{
$configValue = self::create()
->filterByModuleId($moduleId)
->filterByName($variableName)
->findOne();
;
if (null === $configValue) ... | php | {
"resource": ""
} |
q1557 | ModuleConfigQuery.deleteConfigValue | train | public function deleteConfigValue($moduleId, $variableName)
{
if (null !== $moduleConfig = self::create()
->filterByModuleId($moduleId)
->filterByName($variableName)
->findOne()
) {
$moduleConfig->delete();
};
return $this;
} | php | {
"resource": ""
} |
q1558 | Update.auto_update_plugin | train | public function auto_update_plugin( $update, $item ) {
if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) {
return $update;
}
// Old settings.
$pluginAutoupdate = \Boldgrid\Library\Util\Option::get( 'plugin_autoupdate' );
// Update if global setting is on, individual settings is on, or ... | php | {
"resource": ""
} |
q1559 | Update.auto_update_theme | train | public function auto_update_theme( $update, $item ) {
if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) {
return $update;
}
// Old settings.
$themeAutoupdate = \Boldgrid\Library\Util\Option::get( 'theme_autoupdate' );
// Update if global setting is on, individual settings is on, or not... | php | {
"resource": ""
} |
q1560 | RootNode.create | train | public static function create($ns = NULL) {
$node = new RootNode();
$node->addChild(Token::openTag());
if (is_string($ns) && $ns) {
NamespaceNode::create($ns)->appendTo($node)->after(Token::newline());
}
return $node;
} | php | {
"resource": ""
} |
q1561 | RootNode.getNamespace | train | public function getNamespace($ns) {
$namespaces = $this
->getNamespaces()
->filter(function(NamespaceNode $node) use ($ns) {
return $node->getName()->getPath() === $ns;
});
return $namespaces->isEmpty() ? NULL : $namespaces[0];
} | php | {
"resource": ""
} |
q1562 | RootNode.getNamespaceNames | train | public function getNamespaceNames($absolute = FALSE) {
$iterator = function(NamespaceNode $ns) use ($absolute) {
$name = $ns->getName();
return $absolute ? $name->getAbsolutePath() : $name->getPath();
};
return array_map($iterator, $this->getNamespaces()->toArray());
} | php | {
"resource": ""
} |
q1563 | MelisCmsSiteService.getSitePages | train | public function getSitePages($siteId)
{
$results = array();
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
// Sending service start event
$arrayParameters = $this->sendEvent('meliscmssite_service_g... | php | {
"resource": ""
} |
q1564 | MelisCmsSiteService.createSitePage | train | private function createSitePage($siteName, $fatherId, $siteLangId, $pageType, $pageId, $templateId, $platformId)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
// Sending service start event
$arrayParameters = $this->sendEvent('me... | php | {
"resource": ""
} |
q1565 | MelisCmsSiteService.createSitePageTemplate | train | private function createSitePageTemplate($tplId, $siteId, $siteName, $tempName, $controler, $action, $platformId)
{
$cmsTemplateTbl = $this->getServiceLocator()->get('MelisEngineTableTemplate');
$cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds');
// Template data
... | php | {
"resource": ""
} |
q1566 | MelisCmsSiteService.mapDirectory | train | private function mapDirectory($dir, $targetModuleName, $newModuleName)
{
$result = array();
$cdir = scandir($dir);
$fileName = '';
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..")))
{
if (is_dir($dir . '/' . $value))
... | php | {
"resource": ""
} |
q1567 | MelisCmsSiteService.generateModuleNameCase | train | private function generateModuleNameCase($str) {
$i = array("-","_");
$str = preg_replace('/([a-z])([A-Z])/', "$1 $2", $str);
$str = str_replace($i, ' ', $str);
$str = str_replace(' ', '', ucwords(strtolower($str)));
$str = strtolower(substr($str,0,1)).substr($str,1);
$str = ucfirst($str);
... | php | {
"resource": ""
} |
q1568 | FunctionTrait.hasReturnTypes | train | public function hasReturnTypes() {
$doc_comment = $this->getDocComment();
if (!$doc_comment) {
return FALSE;
}
$return_tag = $doc_comment->getReturn();
if (!$return_tag) {
return FALSE;
}
$types = $return_tag->getTypes();
return !empty($types);
} | php | {
"resource": ""
} |
q1569 | FunctionTrait.getReturnTypes | train | public function getReturnTypes() {
$types = ['void'];
$doc_comment = $this->getDocComment();
if (!$doc_comment) {
return $types;
}
$return_tag = $doc_comment->getReturn();
if (!$return_tag) {
return $types;
}
$types = Types::normalize($return_tag->getTypes());
if (empty($... | php | {
"resource": ""
} |
q1570 | Application.setDefaultTimezone | train | protected function setDefaultTimezone()
{
$timezone = 'UTC';
if (is_link('/etc/localtime')) {
// Mac OS X (and older Linuxes)
// /etc/localtime is a symlink to the timezone in /usr/share/zoneinfo.
$filename = readlink('/etc/localtime');
if (strpos($fil... | php | {
"resource": ""
} |
q1571 | UrlRewritingTrait.getUrl | train | public function getUrl($locale = null)
{
if (null === $locale) {
$locale = $this->getLocale();
}
return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString();
} | php | {
"resource": ""
} |
q1572 | UrlRewritingTrait.generateRewrittenUrl | train | public function generateRewrittenUrl($locale)
{
if ($this->isNew()) {
throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName()));
}
// Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-... | php | {
"resource": ""
} |
q1573 | UrlRewritingTrait.getRewrittenUrl | train | public function getRewrittenUrl($locale)
{
$rewritingUrl = RewritingUrlQuery::create()
->filterByViewLocale($locale)
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->filterByRedirected(null)
->findOne()
;
... | php | {
"resource": ""
} |
q1574 | UrlRewritingTrait.markRewrittenUrlObsolete | train | public function markRewrittenUrlObsolete()
{
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
} | php | {
"resource": ""
} |
q1575 | UrlRewritingTrait.setRewrittenUrl | train | public function setRewrittenUrl($locale, $url)
{
$currentUrl = $this->getRewrittenUrl($locale);
if ($currentUrl == $url || null === $url) {
/* no url update */
return $this;
}
try {
$resolver = new RewritingResolver($url);
/* we can ... | php | {
"resource": ""
} |
q1576 | ClassMemberNode.create | train | public static function create($name, ExpressionNode $value = NULL, $visibility = 'public') {
$code = $visibility . ' $' . ltrim($name, '$');
if ($value instanceof ExpressionNode) {
$code .= ' = ' . $value->getText();
}
/** @var ClassNode $class_node */
$class_node = Parser::parseSnippet('class... | php | {
"resource": ""
} |
q1577 | Render.adminBarNode | train | public static function adminBarNode( $wpAdminBar, $configs ) {
$wpAdminBar->add_node( $configs['topLevel'] );
foreach ( $configs['items'] as $item ) {
$wpAdminBar->add_menu( $item );
}
} | php | {
"resource": ""
} |
q1578 | MetaDataQuery.setVal | train | public static function setVal($metaKey, $elementKey, $elementId, $value)
{
$data = self::create()
->filterByMetaKey($metaKey)
->filterByElementKey($elementKey)
->filterByElementId($elementId)
->findOne()
;
if (null === $data) {
$da... | php | {
"resource": ""
} |
q1579 | IdentifierNameTrait.setName | train | public function setName($name) {
/** @var TokenNode $identifier */
$identifier = $this->name->firstChild();
$identifier->setText($name);
return $this;
} | php | {
"resource": ""
} |
q1580 | IdentifierNameTrait.inNamespace | train | public function inNamespace($ns) {
if (is_string($ns)) {
$namespace_node = $this->name->getNamespace();
$namespace = $namespace_node === NULL ? '' : $namespace_node->getName()->getAbsolutePath();
return $ns === $namespace;
}
elseif ($ns instanceof NamespaceNode) {
return $this->name-... | php | {
"resource": ""
} |
q1581 | InfoPresenter.renderServer | train | public function renderServer(): void
{
$this->addBreadcrumbLink('dockbar.info.server');
$this->template->refresh = $this->refresh;
$this->template->system = $this->app->info->system;
$this->template->fileSystem = $this->app->info->fileSystem;
$this->template->hardware = $this->app->info->hardware;
$this->t... | php | {
"resource": ""
} |
q1582 | InfoPresenter.renderPhp | train | public function renderPhp(): void
{
$this->addBreadcrumbLink('dockbar.info.php');
$this->template->php = $this->app->info->phpInfo;
} | php | {
"resource": ""
} |
q1583 | UsersPresenter.setState | train | public function setState(int $id, bool $value): void
{
if ($this->isAjax()) {
$user = $this->orm->users->getById($id);
$user->active = $value;
$this->orm->persistAndFlush($user);
$this['userList']->redrawItem($id);
} else {
$this->terminate();
}
} | php | {
"resource": ""
} |
q1584 | UsersPresenter.createComponentAddForm | train | protected function createComponentAddForm(): Form
{
$form = $this->formFactory->create();
$form->addProtection();
$form->addText('username', 'cms.user.username')
->setRequired();
$form->addText('firstName', 'cms.user.firstName');
$form->addText('surname', 'cms.user.surname');
$form->addText('email', 'c... | php | {
"resource": ""
} |
q1585 | UsersPresenter.addFormSucceeded | train | public function addFormSucceeded(Form $form, ArrayHash $values): void
{
if ($values->generatePassword) {
$password = Random::generate($this->minPasswordLength, $this->passwordChars);
} else {
$password = $values->password;
}
$user = new User;
$this->orm->users->attach($user);
try {
$user->setUser... | php | {
"resource": ""
} |
q1586 | UsersPresenter.createComponentEditForm | train | protected function createComponentEditForm(): Form
{
$form = $this->formFactory->create();
$form->addProtection();
$form->addText('username', 'cms.user.username')
->setDefaultValue($this->currentUser->username)
->setRequired();
$form->addText('firstName', 'cms.user.firstName')
->setDefaultValue($this... | php | {
"resource": ""
} |
q1587 | UsersPresenter.editFormSucceeded | train | public function editFormSucceeded(Form $form, ArrayHash $values): void
{
try {
$this->currentUser->setUsername($values->username);
} catch (UniqueConstraintViolationException $ex) {
$form->addError('cms.user.duplicityUsername');
return;
} catch (InvalidArgumentException $ex) {
$form->addError('cms.us... | php | {
"resource": ""
} |
q1588 | UsersPresenter.passwordFormSucceeded | train | public function passwordFormSucceeded(Form $form, ArrayHash $values): void
{
if ($values->generatePassword) {
$password = Random::generate($this->minPasswordLength, $this->passwordChars);
} else {
$password = $values->password;
}
$this->currentUser->setPassword($password);
$this->orm->persistAndFlush... | php | {
"resource": ""
} |
q1589 | FolderQuery.findAllChild | train | public static function findAllChild($folderId, $depth = 0, $currentPosition = 0)
{
$result = array();
if (\is_array($folderId)) {
foreach ($folderId as $folderSingleId) {
$result = array_merge($result, (array) self::findAllChild($folderSingleId, $depth, $currentPosition)... | php | {
"resource": ""
} |
q1590 | TokenProvider.generateToken | train | public static function generateToken()
{
$raw = self::getOpenSSLRandom();
if (false === $raw) {
$raw = self::getComplexRandom();
}
return md5($raw);
} | php | {
"resource": ""
} |
q1591 | ImportController.indexAction | train | public function indexAction($_view = 'import')
{
$authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::VIEW]);
if ($authResponse !== null) {
return $authResponse;
}
$this->getParserContext()
->set('category_order', $this->getRequest(... | php | {
"resource": ""
} |
q1592 | ImportController.changeImportPositionAction | train | public function changeImportPositionAction()
{
$authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE]);
if ($authResponse !== null) {
return $authResponse;
}
$query = $this->getRequest()->query;
$this->dispatch(
Theli... | php | {
"resource": ""
} |
q1593 | ImportController.matchPositionMode | train | protected function matchPositionMode($mode)
{
if ($mode === 'up') {
return UpdatePositionEvent::POSITION_UP;
}
if ($mode === 'down') {
return UpdatePositionEvent::POSITION_DOWN;
}
return UpdatePositionEvent::POSITION_ABSOLUTE;
} | php | {
"resource": ""
} |
q1594 | ImportController.configureAction | train | public function configureAction($id)
{
/** @var \Thelia\Handler\ImportHandler $importHandler */
$importHandler = $this->container->get('thelia.import.handler');
$import = $importHandler->getImport($id);
if ($import === null) {
return $this->pageNotFound();
}
... | php | {
"resource": ""
} |
q1595 | ImportController.importAction | train | public function importAction($id)
{
/** @var \Thelia\Handler\Importhandler $importHandler */
$importHandler = $this->container->get('thelia.import.handler');
$import = $importHandler->getImport($id);
if ($import === null) {
return $this->pageNotFound();
}
... | php | {
"resource": ""
} |
q1596 | Cache.getMeter | train | public function getMeter($meterIdentifier)
{
// create cache key
$item_key = $this->getCacheKey($meterIdentifier);
// if not cached, go get it
if (!($meter = $this->cacheService->retrieve($item_key))) {
try {
// find specific meter for company and login
... | php | {
"resource": ""
} |
q1597 | Types.normalize | train | public static function normalize($types) {
$normalized_types = [];
foreach ($types as $type) {
switch ($type) {
case 'boolean':
$normalized_types[] = 'bool';
break;
case 'integer':
$normalized_types[] = 'int';
break;
case 'double':
... | php | {
"resource": ""
} |
q1598 | ClassMemberListNode.getTypes | train | public function getTypes() {
// No type specified means type is mixed.
$types = ['mixed'];
// Use types from the doc comment if available.
$doc_comment = $this->getDocComment();
if (!$doc_comment) {
return $types;
}
$doc_block = $doc_comment->getDocBlock();
$var_tags = $doc_block->... | php | {
"resource": ""
} |
q1599 | CommaListNode.prependItem | train | public function prependItem(Node $item) {
if ($this->getItems()->isEmpty()) {
$this->append($item);
}
else {
$this->prepend([
$item,
Token::comma(),
Token::space(),
]);
}
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.