_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2200 | Currency.setDefault | train | public function setDefault(CurrencyUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
// Reset default status
CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDe... | php | {
"resource": ""
} |
q2201 | Currency.delete | train | public function delete(CurrencyDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) {
if ($currency->getByDefault()) {
throw new \RuntimeException(
Translat... | php | {
"resource": ""
} |
q2202 | Activity.getActivityConfigs | train | public function getActivityConfigs( $activity, $config_path ) {
$configs = array();
if ( file_exists( $config_path ) ) {
$configs = require $config_path;
}
return isset( $configs[ $activity ] ) ? $configs[ $activity ] : array();
} | php | {
"resource": ""
} |
q2203 | Activity.getActivityCount | train | public function getActivityCount( $activity ) {
$plugin_activities = $this->getPluginActivities();
return empty( $plugin_activities[ $activity ] ) ? 0 : $plugin_activities[ $activity ];
} | php | {
"resource": ""
} |
q2204 | Activity.getPluginActivities | train | public function getPluginActivities() {
$activities = $this->getActivities();
if ( ! isset( $activities[ $this->plugin ] ) ) {
$activities[ $this->plugin ] = array();
}
return $activities[ $this->plugin ];
} | php | {
"resource": ""
} |
q2205 | Activity.maybeAddRatingPrompt | train | public function maybeAddRatingPrompt( $activity, $config_path ) {
$added = false;
$configs = $this->getActivityConfigs( $activity, $config_path );
if ( isset( $configs['threshold'] ) && $this->getActivityCount( $activity ) >= $configs['threshold'] ) {
$rating_prompt = new \Boldgrid\Library\Library\RatingProm... | php | {
"resource": ""
} |
q2206 | Activity.savePluginActivities | train | public function savePluginActivities( $plugin_activities ) {
$activities = $this->getActivities();
$activities[ $this->plugin ] = $plugin_activities;
return $this->saveActivities( $activities );
} | php | {
"resource": ""
} |
q2207 | ParserContext.cleanFormData | train | protected function cleanFormData(array $data)
{
foreach ($data as $key => $value) {
if (\is_array($value)) {
$data[$key] = $this->cleanFormData($value);
} elseif (\is_object($value)) {
unset($data[$key]);
}
}
return $data;
... | php | {
"resource": ""
} |
q2208 | ParserContext.addForm | train | public function addForm(BaseForm $form)
{
$formErrorInformation = $this->getSession()->getFormErrorInformation();
// Get form field error details
$formFieldErrors = [];
/** @var Form $field */
foreach ($form->getForm()->getIterator() as $field) {
$errors = $fiel... | php | {
"resource": ""
} |
q2209 | ParserContext.getForm | train | public function getForm($formId, $formClass, $formType)
{
if (isset($this->store[$formClass . ":" . $formType]) && $this->store[$formClass . ":" . $formType] instanceof BaseForm) {
return $this->store[$formClass . ":" . $formType];
}
$formErrorInformation = $this->getSession()->... | php | {
"resource": ""
} |
q2210 | ParserContext.clearForm | train | public function clearForm(BaseForm $form)
{
$formErrorInformation = $this->getSession()->getFormErrorInformation();
$formClass = \get_class($form) . ':' . $form->getType();
if (isset($formErrorInformation[$formClass])) {
unset($formErrorInformation[$formClass]);
$th... | php | {
"resource": ""
} |
q2211 | ParserContext.cleanOutdatedFormErrorInformation | train | protected function cleanOutdatedFormErrorInformation()
{
$formErrorInformation = $this->getSession()->getFormErrorInformation();
if (! empty($formErrorInformation)) {
$now = time();
// Cleanup obsolete form information, and try to find the form data
foreach ($fo... | php | {
"resource": ""
} |
q2212 | MailerFactory.sendEmailToShopManagers | train | public function sendEmailToShopManagers($messageCode, $messageParameters = [], $replyTo = [])
{
$storeName = ConfigQuery::getStoreName();
// Build the list of email recipients
$recipients = ConfigQuery::getNotificationEmailsList();
$to = [];
foreach ($recipients as $recipi... | php | {
"resource": ""
} |
q2213 | MailerFactory.createEmailMessage | train | public function createEmailMessage($messageCode, $from, $to, $messageParameters = [], $locale = null, $cc = [], $bcc = [], $replyTo = [])
{
if (null !== $message = MessageQuery::getFromName($messageCode)) {
if ($locale === null) {
$locale = Lang::getDefaultLanguage()->getLocale()... | php | {
"resource": ""
} |
q2214 | MailerFactory.createSimpleEmailMessage | train | public function createSimpleEmailMessage($from, $to, $subject, $htmlBody, $textBody, $cc = [], $bcc = [], $replyTo = [])
{
$instance = $this->getMessageInstance();
$this->setupMessageHeaders($instance, $from, $to, $cc, $bcc, $replyTo);
$instance->setSubject($subject);
// If we do ... | php | {
"resource": ""
} |
q2215 | Template.create | train | public function create(TemplateCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$template = new TemplateModel();
$template
->setDispatcher($dispatcher)
->setLocale($event->getLocale())
->setName($event->getTemplateName(... | php | {
"resource": ""
} |
q2216 | Template.duplicate | train | public function duplicate(TemplateDuplicateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $source = TemplateQuery::create()->findPk($event->getSourceTemplateId())) {
$source->setLocale($event->getLocale());
$createEvent = new TemplateCreat... | php | {
"resource": ""
} |
q2217 | Template.update | train | public function update(TemplateUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) {
$template
->setDispatcher($dispatcher)
->setLocale($event->... | php | {
"resource": ""
} |
q2218 | Template.delete | train | public function delete(TemplateDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($template = TemplateQuery::create()->findPk($event->getTemplateId()))) {
// Check if template is used by a product
$productCount = ProductQuery::create()->findByTempla... | php | {
"resource": ""
} |
q2219 | DoctrineEntityMappingAutodiscoverer.autodiscover | train | public function autodiscover(): void
{
$entityMappings = [];
foreach ($this->fileSystem->getEntityDirectories() as $entityDirectory) {
$namespace = $this->namespaceDetector->detectFromDirectory($entityDirectory);
if (! $namespace) {
continue;
}
... | php | {
"resource": ""
} |
q2220 | AddressController.createFormDataArray | train | protected function createFormDataArray($object)
{
return array(
"label" => $object->getLabel(),
"title" => $object->getTitleId(),
"firstname" => $object->getFirstname(),
"lastname" => $object->getLastname(),
"address1" => $object->getAddress1(),
... | php | {
"resource": ""
} |
q2221 | AddressController.renderEditionTemplate | train | protected function renderEditionTemplate()
{
return $this->render('customer-edit', array(
"address_id" => $this->getRequest()->get('address_id'),
"page" => $this->getRequest()->get('page'),
"customer_id" => $this->getCustomerId()
));
} | php | {
"resource": ""
} |
q2222 | ToolTemplateController.renderToolTemplateHeaderRefreshAction | train | public function renderToolTemplateHeaderRefreshAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | {
"resource": ""
} |
q2223 | ToolTemplateController.renderToolTemplateContentFiltersSitesAction | train | public function renderToolTemplateContentFiltersSitesAction()
{
$translator = $this->getServiceLocator()->get('translator');
$siteTable = $this->getServiceLocator()->get('MelisEngineTableSite');
$sites = array();
$sites[] = '<option value="">'. $translator->translate('tr_meliscms_to... | php | {
"resource": ""
} |
q2224 | ToolTemplateController.renderToolTemplatesModalAddHandlerAction | train | public function renderToolTemplatesModalAddHandlerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what... | php | {
"resource": ""
} |
q2225 | ToolTemplateController.renderToolTemplatesModalEditHandlerAction | train | public function renderToolTemplatesModalEditHandlerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool wha... | php | {
"resource": ""
} |
q2226 | ToolTemplateController.renderToolTemplatesModalEmptyHandlerAction | train | public function renderToolTemplatesModalEmptyHandlerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | {
"resource": ""
} |
q2227 | ToolTemplateController.modalTabToolTemplateAddAction | train | public function modalTabToolTemplateAddAction()
{
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->se... | php | {
"resource": ""
} |
q2228 | ToolTemplateController.getTemplateByPageIdAction | train | public function getTemplateByPageIdAction()
{
$success = 0;
$request = $this->getRequest();
$data = array();
if($request->isPost())
{
$template = $this->getServiceLocator()->get("MelisPageTemplate");
$success = 2;
$data = $template->get... | php | {
"resource": ""
} |
q2229 | ToolTemplateController.getControllers | train | protected function getControllers(string $controllersPath) : array
{
$controllers = [];
// List all controller files inside the ..src/controller folder
if (is_dir($controllersPath)) {
foreach (scandir($controllersPath) as $controller) {
// Skip directory pointers... | php | {
"resource": ""
} |
q2230 | ToolTemplateController.getTemplateDataByIdAction | train | public function getTemplateDataByIdAction()
{
$request = $this->getRequest();
$data = array();
if($request->isPost())
{
$templatesModel = $this->getServiceLocator()->get('MelisEngineTableTemplate');
$templateId = $request->getPost('templateId');
... | php | {
"resource": ""
} |
q2231 | License.ajaxClear | train | public function ajaxClear() {
$plugin = ! empty( $_POST['plugin'] ) ? sanitize_text_field( $_POST['plugin'] ) : null;
if ( empty( $plugin ) ) {
wp_send_json_error( __( 'Unknown plugin.', 'boldgrid-library' ) );
}
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'Access denied.', '... | php | {
"resource": ""
} |
q2232 | License.registerScripts | train | public function registerScripts() {
$handle = 'bglib-license';
wp_register_script(
$handle,
Library\Configs::get( 'libraryUrl' ) . 'src/assets/js/license.js',
'jQuery'
);
$translations = array(
'unknownError' => __( 'Unknown error', 'boldgrid-library' ),
);
wp_localize_script( $handle, 'bglib... | php | {
"resource": ""
} |
q2233 | License.setLicense | train | private function setLicense() {
if ( ! $this->getApiKey() ) {
$license = 'Missing Connect Key';
} else if ( ! ( $license = $this->getTransient() ) || ! $this->isVersionValid( $license ) ) {
delete_site_transient( $this->getKey() );
$license = $this->getRemoteLicense();
}
return $this->license = $licen... | php | {
"resource": ""
} |
q2234 | License.setTransient | train | private function setTransient() {
return ! $this->getTransient() && set_site_transient( $this->getKey(), $this->getLicense(), $this->getExpiration( $this->getData() ) );
} | php | {
"resource": ""
} |
q2235 | License.isValid | train | private function isValid() {
$data = $this->getTransient();
$valid = array( 'key', 'cipher', 'iv', 'data' );
if ( is_object( $data ) ) {
$props = array_keys( get_object_vars( $data ) );
$valid = array_diff( $valid, $props );
}
return empty( $valid );
} | php | {
"resource": ""
} |
q2236 | License.setData | train | private function setData() {
if ( $license = $this->getLicense() ) {
$data = json_decode(
openssl_decrypt(
$license->data,
$license->cipher,
$license->key,
0,
urldecode( $license->iv )
)
);
}
return $this->data = $data;
} | php | {
"resource": ""
} |
q2237 | License.deactivate | train | public function deactivate() {
if ( ! $this->isValid() && Configs::get( 'licenseActivate' ) ) {
delete_site_transient( $this->getKey() );
deactivate_plugins( Configs::get( 'file' ) );
}
} | php | {
"resource": ""
} |
q2238 | License.getRemoteLicense | train | private function getRemoteLicense() {
$call = new Api\Call( Configs::get( 'api' ) . '/api/plugin/getLicense?v=' .
$this->apiVersion );
if ( ! $response = $call->getError() ) {
$response = $call->getResponse()->result->data;
}
return $response;
} | php | {
"resource": ""
} |
q2239 | License.initLicense | train | public function initLicense() {
$this->license = $this->setLicense();
if ( is_object( $this->getLicense() ) ) {
$this->data = $this->setData();
$this->setTransient( $this->getData() );
$licenseData = array( 'licenseData' => $this->getData() );
Configs::set( $licenseData, Configs::get() );
}
} | php | {
"resource": ""
} |
q2240 | License.isPremium | train | public function isPremium( $product ) {
$isPremium = isset( $this->getData()->$product );
$this->licenseString = $isPremium ?
__( 'Premium', 'boldgrid-connect' ) : __( 'Free', 'boldgrid-library' );
return $isPremium;
} | php | {
"resource": ""
} |
q2241 | License.isVersionValid | train | public function isVersionValid( $license ) {
return ( ! empty( $license->version ) && ! empty( $license->iv ) &&
16 === strlen( urldecode( $license->iv ) ) &&
$this->apiVersion === $license->version );
} | php | {
"resource": ""
} |
q2242 | SessionController.applyUserLocale | train | protected function applyUserLocale(UserInterface $user)
{
// Set the current language according to locale preference
$locale = $user->getLocale();
if (null === $lang = LangQuery::create()->findOneByLocale($locale)) {
$lang = Lang::getDefaultLanguage();
}
$this->... | php | {
"resource": ""
} |
q2243 | DatabaseConfigurationSource.addConnection | train | protected function addConnection($name, array $parameters = [], array $envParameters = [])
{
$connectionParameterBag = new ParameterBag($envParameters);
$connectionParameterBag->add($parameters);
$connectionParameterBag->resolve();
$this->connections[$name] = $connectionParameterBag;... | php | {
"resource": ""
} |
q2244 | ShadowTranslateBehavior.setupFieldAssociations | train | public function setupFieldAssociations($fields, $table, $fieldConditions, $strategy)
{
$config = $this->getConfig();
$this->_table->hasMany($config['translationTable'], [
'className' => $config['translationTable'],
'foreignKey' => 'id',
'strategy' => $strategy,
... | php | {
"resource": ""
} |
q2245 | ShadowTranslateBehavior._addFieldsToQuery | train | protected function _addFieldsToQuery(Query $query, array $config)
{
if ($query->isAutoFieldsEnabled()) {
return true;
}
$select = array_filter($query->clause('select'), function ($field) {
return is_string($field);
});
if (!$select) {
ret... | php | {
"resource": ""
} |
q2246 | ShadowTranslateBehavior._iterateClause | train | protected function _iterateClause(Query $query, $name = '', $config = [])
{
$clause = $query->clause($name);
if (!$clause || !$clause->count()) {
return false;
}
$alias = $config['hasOneAlias'];
$fields = $this->_translationFields();
$mainTableAlias = $co... | php | {
"resource": ""
} |
q2247 | ShadowTranslateBehavior._traverseClause | train | protected function _traverseClause(Query $query, $name = '', $config = [])
{
$clause = $query->clause($name);
if (!$clause || !$clause->count()) {
return false;
}
$alias = $config['hasOneAlias'];
$fields = $this->_translationFields();
$mainTableAlias = $c... | php | {
"resource": ""
} |
q2248 | ShadowTranslateBehavior._mainFields | train | protected function _mainFields()
{
$fields = $this->getConfig('mainTableFields');
if ($fields) {
return $fields;
}
$table = $this->_table;
$fields = $table->getSchema()->columns();
$this->setConfig('mainTableFields', $fields);
return $fields;
... | php | {
"resource": ""
} |
q2249 | ShadowTranslateBehavior._translationFields | train | protected function _translationFields()
{
$fields = $this->getConfig('fields');
if ($fields) {
return $fields;
}
$table = $this->_translationTable();
$fields = $table->getSchema()->columns();
$fields = array_values(array_diff($fields, ['id', 'locale']));... | php | {
"resource": ""
} |
q2250 | ModelCriteriaTools.getI18n | train | public static function getI18n(
$backendContext,
$requestedLangId,
ModelCriteria &$search,
$currentLocale,
$columns,
$foreignTable,
$foreignKey,
$forceReturn = false,
$localeAlias = null
) {
// If a lang has been requested, find the rel... | php | {
"resource": ""
} |
q2251 | AnalysisTrait.provideFilesToCheck | train | public function provideFilesToCheck()
{
$iterator = new AppendIterator();
foreach ($this->getPaths() as $path) {
$iterator->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
}
$files = new CallbackFilterIterator($iterator, function ($file) {
... | php | {
"resource": ""
} |
q2252 | Connect.isConnectScreen | train | public function isConnectScreen( $screen ) {
$base = ! empty( $screen->base ) ? $screen->base : null;
return 'settings_page_boldgrid-connect' === $base;
} | php | {
"resource": ""
} |
q2253 | Connect.addScripts | train | public function addScripts() {
if ( $this->isConnectScreen( get_current_screen() ) ) {
// Enqueue bglib-connect js.
$handle = 'bglib-connect';
wp_register_script(
$handle,
Configs::get( 'libraryUrl' ) . 'src/assets/js/connect.js' ,
array( 'jquery' ),
date( 'Ymd' ),
false
);
$trans... | php | {
"resource": ""
} |
q2254 | Connect.saveSettings | train | public function saveSettings() {
// Check user permissions.
if ( ! current_user_can( 'update_plugins' ) ) {
wp_send_json_error( array(
'error' => __( 'User access violation!', 'boldgrid-library' ),
) );
}
// Check security nonce and referer.
if ( ! check_admin_referer( 'boldgrid_library_connect_set... | php | {
"resource": ""
} |
q2255 | Connect.sanitizeSettings | train | public static function sanitizeSettings( array $settings ) {
$result = array();
if ( ! empty( $settings['autoupdate'] ) && is_array( $settings['autoupdate'] ) ) {
foreach ( $settings['autoupdate'] as $category => $itemSetting ) {
$category = sanitize_key( $category );
foreach ( $itemSetting as $id => $... | php | {
"resource": ""
} |
q2256 | HookHelper.trans | train | protected function trans($context, $key)
{
$message = "";
if (array_key_exists($context, $this->messages)) {
if (array_key_exists($key, $this->messages[$context])) {
$message = $this->messages[$context][$key];
}
}
return $message;
} | php | {
"resource": ""
} |
q2257 | CategoryQuery.getPathToCategory | train | public static function getPathToCategory($categoryId)
{
$path = [];
$category = (new CategoryQuery)->findPk($categoryId);
if ($category !== null) {
$path[] = $category;
if ($category->getParent() !== 0) {
$path = array_merge(self::getPathToCategory($... | php | {
"resource": ""
} |
q2258 | Request.getPathInfo | train | public function getPathInfo()
{
$pathInfo = parent::getPathInfo();
$pathLength = \strlen($pathInfo);
if ($pathInfo !== '/' && $pathInfo[$pathLength - 1] === '/'
&& (bool) ConfigQuery::read('allow_slash_ended_uri', false)
) {
if (null === $this->resolvedPathIn... | php | {
"resource": ""
} |
q2259 | Registration.preUpgradePlugin | train | public function preUpgradePlugin( $options ) {
$plugin = ! empty( $options['hook_extra']['plugin'] ) ? $options['hook_extra']['plugin'] : null;
$isBoldgridPlugin = \Boldgrid\Library\Library\Util\Plugin::isBoldgridPlugin( $plugin );
if( $isBoldgridPlugin ) {
/*
* Before this plugin is upgraded, remove it... | php | {
"resource": ""
} |
q2260 | PingdomApi.getDomains | train | public function getDomains() {
$domains = array();
$checks = $this->getChecks();
foreach ($checks as $check) {
$domains[$check->id] = $check->hostname;
}
return $domains;
} | php | {
"resource": ""
} |
q2261 | PingdomApi.getChecks | train | public function getChecks($limit = NULL, $offset = NULL) {
$parameters = array();
if (!empty($limit)) {
$parameters['limit'] = $limit;
if (!empty($offset)) {
$parameters['offset'] = $offset;
}
}
$data = $this->request('GET', 'checks', $parameters);
return $data->checks;
} | php | {
"resource": ""
} |
q2262 | PingdomApi.getCheck | train | public function getCheck($check_id) {
$this->ensureParameters(array('check_id' => $check_id), __METHOD__);
$data = $this->request('GET', "checks/${check_id}");
return $data->check;
} | php | {
"resource": ""
} |
q2263 | PingdomApi.addCheck | train | public function addCheck($check, $defaults = array()) {
$this->ensureParameters(array(
'name' => $check['name'],
'host' => $check['host'],
'url' => $check['url'],
), __METHOD__);
$check += $defaults;
$data = $this->request('POST', 'checks', $check);
return sprintf('Created check %s... | php | {
"resource": ""
} |
q2264 | PingdomApi.pauseCheck | train | public function pauseCheck($check_id) {
$this->ensureParameters(array('check_id' => $check_id), __METHOD__);
$check = array(
'paused' => TRUE,
);
return $this->modifyCheck($check_id, $check);
} | php | {
"resource": ""
} |
q2265 | PingdomApi.unpauseCheck | train | public function unpauseCheck($check_id) {
$this->ensureParameters(array('check_id' => $check_id), __METHOD__);
$check = array(
'paused' => FALSE,
);
return $this->modifyCheck($check_id, $check);
} | php | {
"resource": ""
} |
q2266 | PingdomApi.pauseChecks | train | public function pauseChecks($check_ids) {
$this->ensureParameters(array('check_ids' => $check_ids), __METHOD__);
$parameters = array(
'paused' => TRUE,
);
return $this->modifyChecks($check_ids, $parameters);
} | php | {
"resource": ""
} |
q2267 | PingdomApi.unpauseChecks | train | public function unpauseChecks($check_ids) {
$this->ensureParameters(array('check_ids' => $check_ids), __METHOD__);
$parameters = array(
'paused' => FALSE,
);
return $this->modifyChecks($check_ids, $parameters);
} | php | {
"resource": ""
} |
q2268 | PingdomApi.modifyCheck | train | public function modifyCheck($check_id, $parameters) {
$this->ensureParameters(array(
'check_id' => $check_id,
'parameters' => $parameters,
), __METHOD__);
$data = $this->request('PUT', "checks/${check_id}", $parameters);
return $data->message;
} | php | {
"resource": ""
} |
q2269 | PingdomApi.modifyChecks | train | public function modifyChecks($check_ids, $parameters) {
$this->ensureParameters(array(
'check_ids' => $check_ids,
'parameters' => $parameters,
), __METHOD__);
$parameters['checkids'] = implode(',', $check_ids);
$data = $this->request('PUT', 'checks', $parameters);
return $data->message;
... | php | {
"resource": ""
} |
q2270 | PingdomApi.modifyAllChecks | train | public function modifyAllChecks($parameters) {
$this->ensureParameters(array('parameters' => $parameters), __METHOD__);
$data = $this->request('PUT', 'checks', $parameters);
return $data->message;
} | php | {
"resource": ""
} |
q2271 | PingdomApi.removeCheck | train | public function removeCheck($check_id) {
$this->ensureParameters(array('check_id' => $check_id), __METHOD__);
$data = $this->request('DELETE', "checks/${check_id}");
return $data->message;
} | php | {
"resource": ""
} |
q2272 | PingdomApi.getContacts | train | public function getContacts($limit = NULL, $offset = NULL) {
$parameters = array();
if (!empty($limit)) {
$parameters['limit'] = $limit;
if (!empty($offset)) {
$parameters['offset'] = $offset;
}
}
$data = $this->request('GET', 'contacts', $parameters);
return $data->contact... | php | {
"resource": ""
} |
q2273 | PingdomApi.getAnalysis | train | public function getAnalysis($check_id, $parameters = array()) {
$this->ensureParameters(array('check_id' => $check_id), __METHOD__);
$data = $this->request('GET', "analysis/${check_id}", $parameters);
return $data->analysis;
} | php | {
"resource": ""
} |
q2274 | PingdomApi.getRawAnalysis | train | public function getRawAnalysis($check_id, $analysis_id, $parameters = array()) {
$this->ensureParameters(array(
'check_id' => $check_id,
'analysis_id' => $analysis_id,
), __METHOD__);
$data = $this->request('GET', "analysis/{$check_id}/{$analysis_id}", $parameters);
return $data;
} | php | {
"resource": ""
} |
q2275 | PingdomApi.ensureParameters | train | public function ensureParameters($parameters = array(), $method) {
if (empty($parameters) || empty($method)) {
throw new MissingParameterException(sprintf('%s called without required parameters.', __METHOD__));
}
foreach ($parameters as $parameter => $value) {
if (!isset($value)) {
throw... | php | {
"resource": ""
} |
q2276 | PingdomApi.request | train | public function request($method, $resource, $parameters = array(), $headers = array(), $body = NULL) {
$handle = curl_init();
$headers[] = 'Content-Type: application/json; charset=utf-8';
$headers[] = 'App-Key: ' . $this->api_key;
if (!empty($this->account_email)) {
$headers[] = 'Account-Email: '... | php | {
"resource": ""
} |
q2277 | PingdomApi.buildRequestUrl | train | public function buildRequestUrl($resource, $parameters = array()) {
foreach ($parameters as $property => $value) {
if (is_bool($value)) {
$parameters[$property] = $value ? 'true' : 'false';
}
}
$query = empty($parameters) ? '' : '?' . http_build_query($parameters, NULL, '&');
return ... | php | {
"resource": ""
} |
q2278 | PingdomApi.getError | train | protected function getError($response_data, $status) {
if (!empty($response_data->error)) {
$error = $response_data->error;
$message = sprintf('%s %s: %s',
$error->statuscode,
$error->statusdesc,
$error->errormessage);
}
else {
$message = sprintf('Error code: %s. No... | php | {
"resource": ""
} |
q2279 | Coupon.getArgDefinitions | train | protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createBooleanOrBothTypeArgument('is_enabled'),
Argument::createBooleanTypeArgument('in_use'),
Argument::createAnyListTypeArgument('code... | php | {
"resource": ""
} |
q2280 | Database.prepareSql | train | protected function prepareSql($sql)
{
$sql = str_replace(";',", "-CODE-", $sql);
$sql = trim($sql);
preg_match_all('#DELIMITER (.+?)\n(.+?)DELIMITER ;#s', $sql, $m);
foreach ($m[0] as $k => $v) {
if ($m[1][$k] == '|') {
throw new \RuntimeException('You can... | php | {
"resource": ""
} |
q2281 | Database.backupDb | train | public function backupDb($filename, $tables = '*')
{
$data = [];
// get all of the tables
if ($tables == '*') {
$tables = array();
$result = $this->connection->prepare('SHOW TABLES');
$result->execute();
while ($row = $result->fetch(PDO::FETCH... | php | {
"resource": ""
} |
q2282 | Database.writeFilename | train | private function writeFilename($filename, $data)
{
$f = fopen($filename, "w+");
fwrite($f, implode('', $data));
fclose($f);
} | php | {
"resource": ""
} |
q2283 | Country.toggleVisibility | train | public function toggleVisibility(CountryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$country = $event->getCountry();
$country
->setDispatcher($dispatcher)
->setVisible(!$country->getVisible())
->save();
$event->setCo... | php | {
"resource": ""
} |
q2284 | Cart.addItem | train | public function addItem(CartEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$cart = $event->getCart();
$newness = $event->getNewness();
$append = $event->getAppend();
$quantity = $event->getQuantity();
$currency = $cart->getCurrency();
$customer = $c... | php | {
"resource": ""
} |
q2285 | Cart.updateQuantity | train | protected function updateQuantity(EventDispatcherInterface $dispatcher, CartItem $cartItem, $quantity)
{
$cartItem->setDisptacher($dispatcher);
$cartItem->updateQuantity($quantity)
->save();
return $cartItem;
} | php | {
"resource": ""
} |
q2286 | Cart.doAddItem | train | protected function doAddItem(
EventDispatcherInterface $dispatcher,
CartModel $cart,
$productId,
ProductSaleElements $productSaleElements,
$quantity,
ProductPriceTools $productPrices
) {
$cartItem = new CartItem();
$cartItem->setDisptacher($dispatcher)... | php | {
"resource": ""
} |
q2287 | Cart.findItem | train | protected function findItem($cartId, $productId, $productSaleElementsId)
{
return CartItemQuery::create()
->filterByCartId($cartId)
->filterByProductId($productId)
->filterByProductSaleElementsId($productSaleElementsId)
->findOne();
} | php | {
"resource": ""
} |
q2288 | Cart.findCartItem | train | public function findCartItem(CartEvent $event)
{
// Do not try to find a cartItem if one exists in the event, as previous event handlers
// mays have put it in th event.
if (null === $event->getCartItem() && null !== $foundItem = CartItemQuery::create()
->filterByCartId($event->g... | php | {
"resource": ""
} |
q2289 | Cart.restoreCurrentCart | train | public function restoreCurrentCart(CartRestoreEvent $cartRestoreEvent, $eventName, EventDispatcherInterface $dispatcher)
{
$cookieName = ConfigQuery::read("cart.cookie_name", 'thelia_cart');
$persistentCookie = ConfigQuery::read("cart.use_persistent_cookie", 1);
$cart = null;
if ($... | php | {
"resource": ""
} |
q2290 | Cart.manageNonPersistentCookie | train | protected function manageNonPersistentCookie(CartRestoreEvent $cartRestoreEvent, EventDispatcherInterface $dispatcher)
{
$cart = $cartRestoreEvent->getCart();
if (null === $cart) {
$cart = $this->dispatchNewCart($dispatcher);
} else {
$cart = $this->manageCartDuplica... | php | {
"resource": ""
} |
q2291 | Cart.createEmptyCart | train | public function createEmptyCart(CartCreateEvent $cartCreateEvent)
{
$cart = new CartModel();
$cart->setCurrency($this->getSession()->getCurrency(true));
/** @var CustomerModel $customer */
if (null !== $customer = $this->getSession()->getCustomerUser()) {
$cart->setCust... | php | {
"resource": ""
} |
q2292 | Cart.duplicateCart | train | protected function duplicateCart(EventDispatcherInterface $dispatcher, CartModel $cart, CustomerModel $customer = null)
{
$newCart = $cart->duplicate(
$this->generateCartCookieIdentifier(),
$customer,
$this->getSession()->getCurrency(),
$dispatcher
);
... | php | {
"resource": ""
} |
q2293 | Cart.generateCartCookieIdentifier | train | protected function generateCartCookieIdentifier()
{
$id = null;
if (ConfigQuery::read("cart.use_persistent_cookie", 1) == 1) {
$id = $this->tokenProvider->getToken();
$this->getSession()->set('cart_use_cookie', $id);
}
return $id;
} | php | {
"resource": ""
} |
q2294 | Content.addCriteriaToPositionQuery | train | protected function addCriteriaToPositionQuery($query)
{
$contents = ContentFolderQuery::create()
->filterByFolderId($this->getDefaultFolderId())
->filterByDefaultFolder(true)
->select('content_id')
->find();
// Filtrer la requete sur ces produits
... | php | {
"resource": ""
} |
q2295 | Update.getDatabasePDO | train | protected function getDatabasePDO()
{
$configPath = THELIA_CONF_DIR . "database.yml";
if (!file_exists($configPath)) {
throw new UpdateException("Thelia is not installed yet");
}
$definePropel = new DatabaseConfigurationSource(
Yaml::parse(file_get_contents(... | php | {
"resource": ""
} |
q2296 | Update.getDataBaseSize | train | public function getDataBaseSize()
{
$stmt = $this->connection->query(
"SELECT sum(data_length) / 1024 / 1024 'size' FROM information_schema.TABLES WHERE table_schema = DATABASE() GROUP BY table_schema"
);
if ($stmt->rowCount()) {
return \floatval($stmt->fetch(PDO::FE... | php | {
"resource": ""
} |
q2297 | Update.checkBackupIsPossible | train | public function checkBackupIsPossible()
{
$size = 0;
if (preg_match('/^(\d+)(.)$/', ini_get('memory_limit'), $matches)) {
switch (strtolower($matches[2])) {
case 'k':
$size = $matches[1] / 1024;
break;
case 'm':
... | php | {
"resource": ""
} |
q2298 | Update.addPostInstructions | train | protected function addPostInstructions($version, $instructions)
{
if (!isset($this->postInstructions[$version])) {
$this->postInstructions[$version] = [];
}
$this->postInstructions[$version][] = $instructions;
} | php | {
"resource": ""
} |
q2299 | Update.getPostInstructions | train | public function getPostInstructions($format = 'plain')
{
$content = [];
if (\count($this->postInstructions) == 0) {
return null;
}
ksort($this->postInstructions);
foreach ($this->postInstructions as $version => $instructions) {
$content[] = sprintf(... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.