_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q7300
DiagramUML.getAttributes
train
public function getAttributes(\DOMElement $diaObject) { $xpath = $diaObject->getNodePath() . '/dia:attribute[@name="attributes"]/*'; $nodeList = $this->engine->query($xpath); if ($nodeList->length > 0) { return $nodeList; } return false; }
php
{ "resource": "" }
q7301
DiagramUML.getElement
train
public function getElement(\DOMElement $nodeList, $level = 0, $showPaths = false) { $tabs = str_repeat("\t", $level); $output = ''; if (!$showPaths) { $output = ""; foreach ($nodeList as $attribute) { $output .= $tabs . $attribute->nodeName . " = " . $...
php
{ "resource": "" }
q7302
DiagramUML.getPaths
train
public function getPaths(\DOMElement $nodeList, $level = 0) { $output = $nodeList->getNodePath(); foreach ($nodeList->childNodes as $childObject) { $output .= $childObject->getNodePath() . "\n"; if ($childObject instanceof \DOMElement) { $output .= $this->ge...
php
{ "resource": "" }
q7303
DiagramUML.retriveAttributeType
train
public function retriveAttributeType(\DOMElement $element) { $name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="type"]/dia:string'); return $this->cleanString($name->item(0)->nodeValue); }
php
{ "resource": "" }
q7304
DiagramUML.retriveAttributeVisibility
train
public function retriveAttributeVisibility(\DOMElement $element) { $name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="visibility"]/dia:enum'); $propertyVisibility = $name->item(0)->attributes->getNamedItem('val')->nodeValue; return self::$propertyVisibilityTypes[$...
php
{ "resource": "" }
q7305
DiagramUML.retriveLayerObjects
train
public function retriveLayerObjects() { $classes = []; foreach ($this->engine->query('//dia:diagram/dia:layer') as $layer) { if ($layer->nodeName == 'dia:layer') { foreach ($layer->childNodes as $elementObject) { if ($elementObject->nodeName == 'dia:ob...
php
{ "resource": "" }
q7306
AbstractCURLRequest.mergeHeaders
train
private function mergeHeaders() { // Initialize the merged headers. $mergedHeaders = []; // Handle each header. foreach (array_merge($this->getConfiguration()->getHeaders(), $this->getHeaders()) as $key => $value) { $mergedHeaders[] = implode(": ", [$key, $value]); ...
php
{ "resource": "" }
q7307
AbstractCURLRequest.mergeURL
train
private function mergeURL() { // Initialize the merged URL. $mergedURL = []; $mergedURL[] = $this->getConfiguration()->getHost(); if (null !== $this->getResourcePath() && "" !== $this->getResourcePath()) { $mergedURL[] = $this->getResourcePath(); } // Retu...
php
{ "resource": "" }
q7308
AbstractCURLRequest.parseHeader
train
private function parseHeader($rawHeader) { // Initialize the headers. $headers = []; $key = ""; // Handle each header. foreach (explode("\n", $rawHeader) as $h) { $h = explode(":", $h, 2); if (true === isset($h[1])) { if (false === is...
php
{ "resource": "" }
q7309
FabricationEngine.registerNamespace
train
public function registerNamespace($prefix, $uri) { $this->initializeXPath(); $this->xpath->registerNamespace($prefix, $uri); }
php
{ "resource": "" }
q7310
FabricationEngine.getSpecification
train
public function getSpecification($element = '') { if (isset($element) && $element !== '') { $spec = $this->pattern->specification[$this->getOption('doctype')][$element]; } else { $spec = $this->pattern->specification[$this->getOption('doctype')]; } retu...
php
{ "resource": "" }
q7311
FabricationEngine.run
train
public function run($data = '', $load = 'string', $type = 'html') { if (!empty($data)) { $this->$type = $type; // Check if data is a path to a valid file then load into buffer. if (file_exists($data)) { $pathHash = md5($data); $thi...
php
{ "resource": "" }
q7312
FabricationEngine.mapSymbols
train
public function mapSymbols() { foreach ($this->input as $key => $input) { foreach ($this->symbols as $skey => $svalue) { if (substr($key, 0, 1) == $svalue) { $keyWithoutSymbol = str_replace($svalue, '', $key); if (is_string($input...
php
{ "resource": "" }
q7313
FabricationEngine.saveHTML
train
public function saveHTML($path = '', $trim = true) { if (is_string($path) && $path !== '') { // no processing as just return xpath html result no adding doctype. $this->output['raw'] = $this->view($path); } else { $this->output['raw'] = parent::saveHTML(); ...
php
{ "resource": "" }
q7314
FabricationEngine.saveFabric
train
public function saveFabric($type = 'html') { switch ($type) { case 'html': $this->output['raw'] = parent::saveHTML(); break; case 'xml': $this->output['raw'] = parent::saveXML(); break; } //...
php
{ "resource": "" }
q7315
FabricationEngine.outputProcess
train
public function outputProcess() { // remove doctype. $this->output['raw'] = preg_replace( '/^<!DOCTYPE[^>]+>/U', '', $this->output['raw'] ); if ($this->outputProcess && $this->getOption('process')) { // Remove doctype added by DOMDocument (hacky...
php
{ "resource": "" }
q7316
FabricationEngine.dump
train
public static function dump($data, $return = false) { $result = ''; if (Fabrication::isCli()) { $end = "\n"; } else { $end = "<br />\n"; } if (is_object($data)) { $classname = get_class($data); $result = str_re...
php
{ "resource": "" }
q7317
FabricationEngine.createPattern
train
public function createPattern($name = 'html', $attributes = array(), $data = array()) { $patternName = ucfirst($name); $objectName = 'Library\Pattern\\' . $patternName; $pattern = new $objectName($this, $attributes, $data); return $pattern; }
php
{ "resource": "" }
q7318
FabricationEngine.specification
train
public function specification($pattern = 'html', $value = '', $attributes = [], $contract = []) { if (!is_array($contract)) { return; } // create the root specification element. $this->appendChild( $this->create($pattern, $value, $attributes, $con...
php
{ "resource": "" }
q7319
FabricationEngine.template
train
public function template($pattern, $dataset = array(), $map = 'id') { if (count($dataset) == 0) { return false; } try { $template = ''; if (is_string($pattern)) { $engine = new FabricationEngine(); ...
php
{ "resource": "" }
q7320
FabricationEngine.view
train
public function view($path = '', $trim = true, $return = true) { if (!empty($path)) { $results = $this->query($path); // create an empty template object for xpath query results. $template = new FabricationEngine(); foreach ($results as $result) { ...
php
{ "resource": "" }
q7321
FabricationEngine.query
train
public function query($path) { $this->initializeXPath(); if ($path) { return $this->xpath->query($path); } return false; }
php
{ "resource": "" }
q7322
FabricationEngine.output
train
public function output($key = '', $query = '', $options = array()) { // ensure key based retrievals are returned first/fast if empty query. if (empty($query) && isset($this->input[$key])) { return $this->input[$key]; } // setup standard options. if (empty...
php
{ "resource": "" }
q7323
FabricationEngine.convert
train
public function convert($data) { $data = trim($data); try { // Buffer engine used to convert the html string into DOMElements, $engine = new FabricationEngine; $engine->run($data); // Check if the body is null, so use the head if avaliable...
php
{ "resource": "" }
q7324
FabricationEngine.htmlToElement
train
public function htmlToElement($html) { // Buffer engine used to convert the html string into DOMElements, $fabrication = new FabricationEngine; $fabrication->run($html); // Retrive xpath element from the FabricationEngine. $element = $this->query('//html/body')->item(...
php
{ "resource": "" }
q7325
FabricationEngine.setElementBy
train
public function setElementBy($element, $value, $nodeValue) { $xql = "//*[@$element='$value']"; if (is_object($nodeValue)) { $result = $this->query($xql)->item(0)->appendChild($this->importNode($nodeValue, true)); } else { $result = $this->query($xql)->item(0)-...
php
{ "resource": "" }
q7326
FabricationEngine.setHtml
train
public function setHtml($q, $value) { $this->getHtml($q)->item(0)->nodeValue = "$value"; return $this->getHtml($q)->item(0); }
php
{ "resource": "" }
q7327
FabricationEngine.timeTaken
train
public function timeTaken() { $timeStop = microtime(true); $timeTaken = (float) substr(-($this->timeStarted - $timeStop), 0, 5); return $timeTaken; }
php
{ "resource": "" }
q7328
CustomFields.getFields
train
public static function getFields(string $module) { $modules = Modules::findFirstByName($module); if ($modules) { return self::find([ 'modules_id = ?0', 'bind' => [$modules->id], 'columns' => 'name, label, type' ]); } ...
php
{ "resource": "" }
q7329
AbstractNode.addNode
train
public function addNode(AbstractNode $node) { $node->parent = $this; $this->index[$node->id] = count($this->nodes); $this->nodes[] = $node; return $this; }
php
{ "resource": "" }
q7330
AbstractNode.getNodeAt
train
public function getNodeAt($position) { if (0 <= $position && $position <= count($this->nodes) - 1) { return $this->nodes[$position]; } return null; }
php
{ "resource": "" }
q7331
AbstractNode.getNodeById
train
public function getNodeById($id, $recursively = false) { $found = null; if (true === array_key_exists($id, $this->index)) { $found = $this->getNodeAt($this->index[$id]); } if (null === $found && true === $recursively) { foreach ($this->nodes as $current) { ...
php
{ "resource": "" }
q7332
AbstractNode.removeNode
train
public function removeNode(AbstractNode $node) { if (true === array_key_exists($node->id, $this->index)) { unset($this->nodes[$this->index[$node->id]]); unset($this->index[$node->id]); $node->parent = null; } return $this; }
php
{ "resource": "" }
q7333
Router.getDocBlockFactory
train
public static function getDocBlockFactory(): DocBlockFactory { if (is_null(self::$docBlockFactory)) { self::$docBlockFactory = DocBlockFactory::createInstance(); } return self::$docBlockFactory; }
php
{ "resource": "" }
q7334
Router.getHttpMethod
train
private function getHttpMethod(): string { if (!empty($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $method = mb_strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); } else { $method = mb_strtoupper($_SERVER['REQUEST_METHOD']); } switch ($method) { ...
php
{ "resource": "" }
q7335
Router.getHttpPath
train
private function getHttpPath(): ?string { $path = null; if (isset($_SERVER['REQUEST_URI'])) { $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); } return $path; }
php
{ "resource": "" }
q7336
Router.getHttpHeaders
train
protected function getHttpHeaders(string $prefix = null): array { $headers = []; // Get all headers if (function_exists('\getallheaders')) { $headers = \getallheaders() ?: []; } else { foreach ($_SERVER as $name => $value) { if (substr($name, ...
php
{ "resource": "" }
q7337
RdfHelpers.getNodeInSparqlFormat
train
public function getNodeInSparqlFormat(Node $node, $var = null) { if ($node->isConcrete()) { return $node->toNQuads(); } if (null !== $var) { return '?'.$var; } else { return '?'.uniqid('tempVar'); } }
php
{ "resource": "" }
q7338
RdfHelpers.getQueryType
train
public function getQueryType($query) { /** * First we get rid of all PREFIX information. */ $adaptedQuery = preg_replace('/PREFIX\s+[a-z0-9\-]+\:\s*\<[a-z0-9\:\/\.\#\-\~\_]+\>/si', '', $query); // remove whitespace lines and trailing whitespaces $adaptedQuery = pre...
php
{ "resource": "" }
q7339
ArraySerialized._afterLoad
train
public function _afterLoad() { $value = $this->getValue(); /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ /** @noinspection PhpParamsInspection */ $this->setValue(empty($value) ? false : $this->encoder->decode($value)); parent::_afterLoad(); }
php
{ "resource": "" }
q7340
ArraySerialized.removeDuplicates
train
public function removeDuplicates($values) { foreach ($values as $key => $option) { $value = $this->getCmsPageValue($option); if ($value) { if ($this->listHasValue($value)) { unset($values[$key]); } else { $this->...
php
{ "resource": "" }
q7341
ParserFactoryHardf.createParserFor
train
public function createParserFor($serialization) { if (!in_array($serialization, $this->getSupportedSerializations())) { throw new \Exception( 'Requested serialization '.$serialization.' is not available in: '. implode(', ', $this->getSupportedSerializations()) ...
php
{ "resource": "" }
q7342
Encoder.decode
train
public function decode($string) { if ($this->isSerialized($string)) { return $this->unserialize($string); } $result = json_decode($string, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new \InvalidArgumentException('Unable to unserialize value.');...
php
{ "resource": "" }
q7343
Encoder.unserialize
train
private function unserialize($string) { if (false === $string || null === $string || '' === $string) { throw new \InvalidArgumentException('Unable to unserialize value.'); } set_error_handler( function () { restore_error_handler(); thro...
php
{ "resource": "" }
q7344
BasicBacktraceReporter.getBacktrace
train
public function getBacktrace($exception = null) { $skipLimit = false; if ($exception instanceof \Exception || $exception instanceof \Throwable) { $backtrace = $exception->getTrace(); foreach ($backtrace as $index => $backtraceCall) { unset($backtrace[$index][...
php
{ "resource": "" }
q7345
ArrayHelper.BEM
train
public function BEM($block = null, $element = null, $modifiers = []): array { if (!isset($block) || !is_string($block) || !$block) { return []; } $baseClass = $element ? "{$block}__{$element}" : "{$block}"; $classes = [$baseClass]; if (isset($modifiers)) { ...
php
{ "resource": "" }
q7346
ArrayHelper.modifierArray
train
private static function modifierArray($modifiers = []): array { if (is_string($modifiers)) { return [$modifiers]; } $array = []; if (is_array($modifiers)) { foreach ($modifiers as $key => $value) { if (!$value) { continue; ...
php
{ "resource": "" }
q7347
ArrayHelper.join
train
public function join(array $array, string $separator = ','): string { $result = ''; foreach ($array as $item) { if (is_array($item)) { $result .= $this->join($item, $separator) . $separator; } else { $result .= $item . $separator; ...
php
{ "resource": "" }
q7348
ArrayHelper.extractSubElements
train
public function extractSubElements( array $array, bool $preserveKeys = false ): array { $resultArray = []; foreach ($array as $element) { if (is_array($element)) { foreach ($element as $subKey => $subElement) { if ($preserveKeys) { ...
php
{ "resource": "" }
q7349
Asset.outputStyles
train
public static function outputStyles($output = '') { self::lookIfProcessFiles('style', 'header'); $template = self::$templates['style']; $styles = self::$data['style']['header']; foreach ($styles as $value) { $output .= sprintf( $template, ...
php
{ "resource": "" }
q7350
Asset.isAdded
train
public static function isAdded($type, $name) { if (isset(self::$data[$type]['header'][$name])) { return true; } elseif (isset(self::$data[$type]['footer'][$name])) { return true; } return false; }
php
{ "resource": "" }
q7351
Asset.unify
train
public static function unify($uniqueID, $params, $minify = false) { self::$id = $uniqueID; self::$unify = $params; self::$minify = $minify; return true; }
php
{ "resource": "" }
q7352
Asset.remove
train
public static function remove($type, $name) { if (isset(self::$data[$type]['header'][$name])) { unset(self::$data[$type]['header'][$name]); return true; } elseif (isset(self::$data[$type]['footer'][$name])) { unset(self::$data[$type]['footer'][$name]); ...
php
{ "resource": "" }
q7353
Asset.lookIfProcessFiles
train
protected static function lookIfProcessFiles($type, $place) { if (is_string(self::$unify) || isset(self::$unify[$type . 's'])) { return self::unifyFiles( self::prepareFiles($type, $place) ); } }
php
{ "resource": "" }
q7354
Asset.prepareFiles
train
protected static function prepareFiles($type, $place) { self::getProcessedFiles(); $params['type'] = $type; $params['place'] = $place; $params['routes'] = self::getRoutesToFolder($type); foreach (self::$data[$type][$place] as $id => $file) { $path = self::getPat...
php
{ "resource": "" }
q7355
Asset.getRoutesToFolder
train
protected static function getRoutesToFolder($type) { $type = $type . 's'; $url = isset(self::$unify[$type]) ? self::$unify[$type] : self::$unify; return ['url' => $url, 'path' => self::getPathFromUrl($url)]; }
php
{ "resource": "" }
q7356
Asset.isModifiedHash
train
protected static function isModifiedHash($url, $path) { if (self::isExternalUrl($url)) { if (sha1_file($url) !== sha1_file($path)) { return self::$changes = true; } } return false; }
php
{ "resource": "" }
q7357
Asset.unifyFiles
train
protected static function unifyFiles($params, $data = '') { $type = $params['type']; $place = $params['place']; $routes = $params['routes']; $ext = ($type == 'style') ? '.css' : '.js'; $hash = sha1(implode('', $params['files'])); $minFile = $routes['path'] . $hash . $...
php
{ "resource": "" }
q7358
Asset.saveExternalFile
train
protected static function saveExternalFile($url, $path) { if ($data = file_get_contents($url)) { return (self::saveFile($path, $data)) ? $data : ''; } return ''; }
php
{ "resource": "" }
q7359
Asset.compressFiles
train
protected static function compressFiles($content) { $var = ["\r\n", "\r", "\n", "\t", ' ', ' ', ' ']; $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content); $content = str_replace($var, '', $content); $content = str_replace('{ ', '{', $content); $con...
php
{ "resource": "" }
q7360
Asset.setNewParams
train
protected static function setNewParams($type, $place, $hash, $url, $ext) { $data = [ 'name' => self::$id, 'url' => $url . $hash . $ext, 'attr' => self::unifyParams($type, 'attr'), 'version' => self::unifyParams($type, 'version', '1.0.0'), ]; i...
php
{ "resource": "" }
q7361
Asset.unifyParams
train
protected static function unifyParams($type, $field, $default = '') { $data = array_column(self::$data[$type], $field); switch ($field) { case 'attr': case 'footer': case 'version': foreach ($data as $value) { if ($data[0] !== ...
php
{ "resource": "" }
q7362
SgCore.retrievePathScope
train
private function retrievePathScope($path, $shopNumber) { $shopConfigs = $this->getShopNumberCollection($shopNumber); if (!$shopConfigs->getSize()) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_UNKNOWN_SHOP_NUMBER, false, true); } $firstItem =...
php
{ "resource": "" }
q7363
MigrationsLocator.getMigrationsLocations
train
public function getMigrationsLocations() { $migrationsLocations = []; foreach ($this->kernel->getBundles() as $bundle) { $migrationsLocation = $this->createMigrationsLocation($bundle); if ($this->filesystem->exists($migrationsLocation->getDirectory())) { $migr...
php
{ "resource": "" }
q7364
MigrationsLocator.createMigrationsLocation
train
public function createMigrationsLocation(BundleInterface $bundle) { return new MigrationsLocation( $bundle->getPath() . '/' . $this->relativeDirectory, $bundle->getNamespace() . '\\' . $this->relativeNamespace ); }
php
{ "resource": "" }
q7365
Customer.setEntity
train
public function setEntity(MageQuote $quote) { $id = $this->sgBase->getExternalCustomerId(); $email = $this->sgBase->getMail(); try { $customer = $id ? $this->customerHelper->getById($id) : $this->customerHelper->getByEmail($email); } catch (NoSuchEntityException $e) {...
php
{ "resource": "" }
q7366
Customer.setAddress
train
public function setAddress(MageQuote $quote) { $billing = $this->sgBase->getInvoiceAddress(); if (!empty($billing)) { $data = $this->sgCustomer->createAddressData($this->sgBase, $billing, $quote->getCustomerId()); $quote->getBillingAddress() ->addData($data)...
php
{ "resource": "" }
q7367
Customer.resetGuest
train
public function resetGuest(MageQuote $quote) { if ($this->sgBase->isGuest()) { $quote->getBillingAddress()->isObjectNew(false); $quote->getShippingAddress()->isObjectNew(false); } }
php
{ "resource": "" }
q7368
DiContainer.setValue
train
public function setValue($name, $value) { if (substr($name, -1) === '_') { throw new InvalidArgumentException('$name cannot end with "_"'); } $this->remove($name); $this->{$name} = $value; return $this; }
php
{ "resource": "" }
q7369
DiContainer.setClassName
train
public function setClassName($name, $class_name, $shared = true) { if (substr($name, -1) === '_') { throw new InvalidArgumentException('$name cannot end with "_"'); } $classname_pattern = self::CLASS_NAME_PATTERN_53; if (!is_string($class_name) || !preg_match($classname_pattern, $class_name)) { throw new ...
php
{ "resource": "" }
q7370
DiContainer.remove
train
public function remove($name) { if (substr($name, -1) === '_') { throw new InvalidArgumentException('$name cannot end with "_"'); } unset($this->{$name}); unset($this->factories_[$name]); return $this; }
php
{ "resource": "" }
q7371
DiContainer.has
train
public function has($name) { if (isset($this->factories_[$name])) { return true; } if (substr($name, -1) === '_') { return false; } return (bool)property_exists($this, $name); }
php
{ "resource": "" }
q7372
AbstractChartAccountsModel.addAccount
train
public function addAccount(ChartAccountsAccount $account) { foreach ($this->accounts as $current) { if ($current->getNumber() === $account->getNumber()) { throw new AccountAlreadyExistsException($account); } } $this->accounts[] = $account; return $...
php
{ "resource": "" }
q7373
AbstractChartAccountsModel.removeAccount
train
public function removeAccount(ChartAccountsAccount $account) { for ($i = count($this->accounts) - 1; 0 <= $i; --$i) { if ($account->getNumber() !== $this->accounts[$i]->getNumber()) { continue; } unset($this->accounts[$i]); } return $this; ...
php
{ "resource": "" }
q7374
CmsMap.getCmsPageRenderer
train
protected function getCmsPageRenderer() { if (!$this->cmsPageRenderer) { $this->cmsPageRenderer = $this->getLayout()->createBlock( 'Shopgate\Base\Block\Adminhtml\Form\Field\CmsMap', '', ['data' => ['is_render_to_js_template' => true]] )...
php
{ "resource": "" }
q7375
Filer.routes
train
public static function routes(Router $router, $namespace = 'TeamTeaTime\Filer\Controllers') { $router->group(compact('namespace'), function ($router) { $router->get('{id}', [ 'as' => 'filer.file.view', 'uses' => 'LocalFileController@view' ]); ...
php
{ "resource": "" }
q7376
Filer.checkType
train
public static function checkType($item) { if (is_string($item)) { // Item is a string; check to see if it's a URL or filepath if (filter_var($item, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) { // Item is a URL return Type::URL; } else...
php
{ "resource": "" }
q7377
Filer.getRelativeFilepath
train
public static function getRelativeFilepath($file) { $storageDir = self::convertSlashes(config('filer.path.absolute')); $absolutePath = self::convertSlashes($file->getRealPath()); return dirname(str_replace($storageDir, '', $absolutePath)); }
php
{ "resource": "" }
q7378
Net_SFTP._setstat
train
function _setstat($filename, $attr, $recursive) { if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { return false; } $filename = $this->_realpath($filename); if ($filename === false) { return false; } $this->_remove_from_stat_cache($fil...
php
{ "resource": "" }
q7379
Net_SFTP.rename
train
function rename($oldname, $newname) { if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { return false; } $oldname = $this->_realpath($oldname); $newname = $this->_realpath($newname); if ($oldname === false || $newname === false) { return false; ...
php
{ "resource": "" }
q7380
OrderItem.getStackQty
train
public function getStackQty() { $info = $this->getInternalOrderInfo(); $qty = 1; if ($info->getStackQuantity() > 1) { $qty = $info->getStackQuantity(); } return $qty; }
php
{ "resource": "" }
q7381
OrderItem.setInternalOrderInfo
train
public function setInternalOrderInfo($value) { if ($value instanceof ItemInfo) { $value = $value->toJson(); } elseif (is_array($value)) { $value = \Zend_Json_Encoder::encode($value); } return parent::setInternalOrderInfo($value); }
php
{ "resource": "" }
q7382
OrderItem.setMagentoError
train
public function setMagentoError($errorText) { $code = $this->translateMagentoError($errorText); $message = \ShopgateLibraryException::getMessageFor($code); $this->setUnhandledError($code, $message); return $this; }
php
{ "resource": "" }
q7383
OrderItem.getExportProductId
train
public function getExportProductId() { return $this->getInternalOrderInfo()->getItemType() == Grouped::TYPE_CODE ? $this->getChildId() : $this->getParentId(); }
php
{ "resource": "" }
q7384
Status.validate
train
private function validate() { if (!array_key_exists('type', $this->properties)) { throw new StatusException(sprintf('Key %s in %s missing', 'type', __CLASS__), 100, null); } $type = $this->properties['type']; // the type specified must be valid if (!in_array($th...
php
{ "resource": "" }
q7385
CollectionWorkflowAbstract.has_more
train
public function has_more() { if ($this->_pointer + 1 == count($this->_collection)) { return false; } ++$this->_pointer; return true; }
php
{ "resource": "" }
q7386
Error.line
train
static function line($message = '', $newLine = 'after') { if($newLine == 'before' || $newLine == 'both') { echo PHP_EOL; } echo self::formatMessage("Error. $message", ['fg-red']); if($newLine == 'after' || $newLine == 'both') { echo PHP_EOL; } }
php
{ "resource": "" }
q7387
Error.formatMessage
train
private static function formatMessage($message, $styles) { if (empty($styles) || !self::ansiColorsSupported()) { return $message; } return sprintf("\x1b[%sm", implode(';', array_map('Output::getStyleCode', $styles))) . $message . "\x1b[0m"; }
php
{ "resource": "" }
q7388
IconFactory.getSizes
train
public function getSizes(\ElggEntity $entity, array $icon_sizes = array()) { $defaults = ($entity && $entity->getSubtype() == 'file') ? $this->config->getFileIconSizes() : $this->config->getGlobalIconSizes(); $sizes = array_merge($defaults, $icon_sizes); return elgg_trigger_plugin_hook('entity:icon:sizes', $ent...
php
{ "resource": "" }
q7389
IconFactory.getIconDirectory
train
public function getIconDirectory(\ElggEntity $entity, $size = null, $directory = null) { $sizes = $this->getSizes($entity); if (isset($sizes[$size]['metadata_name'])) { $md_name = $sizes[$size]['metadata_name']; if ($entity->$md_name) { $directory = ''; } } if ($directory === null) { $director...
php
{ "resource": "" }
q7390
IconFactory.getIconFilename
train
public function getIconFilename(\ElggEntity $entity, $size = '') { $mimetype = $entity->icon_mimetype ? : $entity->mimetype; switch ($mimetype) { default : $ext = 'jpg'; break; case 'image/png' : $ext = 'png'; break; case 'image/gif' : $ext = 'gif'; break; } $sizes = $this->ge...
php
{ "resource": "" }
q7391
IconFactory.getIconFile
train
public function getIconFile(\ElggEntity $entity, $size = '') { $dir = $this->getIconDirectory($entity, $size); $filename = $this->getIconFilename($entity, $size); if ($entity instanceof \ElggUser) { $owner_guid = $entity->guid; } else if ($entity->owner_guid) { $owner_guid = $entity->owner_guid; } els...
php
{ "resource": "" }
q7392
IconFactory.getURL
train
public function getURL(\ElggEntity $entity, $size = '') { $icon = $this->getIconFile($entity, $size); if (!$icon->exists()) { return; } $key = get_site_secret(); $guid = $entity->guid; $path = $icon->getFilename(); $hmac = hash_hmac('sha256', $guid . $path, $key); $query = serialize(array( '...
php
{ "resource": "" }
q7393
IconFactory.outputRawIcon
train
public function outputRawIcon($entity_guid, $size = null) { if (headers_sent()) { exit; } $ha = access_get_show_hidden_status(); access_show_hidden_entities(true); $entity = get_entity($entity_guid); if (!$entity) { exit; } $size = strtolower($size ? : 'medium'); $filename = "icons/" . $entity->...
php
{ "resource": "" }
q7394
Configuration.getMigrationsToExecute
train
public function getMigrationsToExecute($direction, $to) { if ($direction === Version::DIRECTION_DOWN) { $this->throwMethodIsNotAllowedException('Migration down is not allowed.'); } $migrationVersionsToExecute = []; $allMigrationVersions = $this->getMigrations(); ...
php
{ "resource": "" }
q7395
GCode.drawCircle
train
public function drawCircle($x, $y, $z, $radius, $motion = 'G2', $plane = 'G17') { if ($plane == 'G17') { $of = $x - $radius; $this->setCode("(circle)"); $this->setCode("G0 X{$of} Y{$y}"); $this->setCode("G1 Z{$z} (axis spindle start point)"); // TODO Tool size ... // TODO Cutting sp...
php
{ "resource": "" }
q7396
GCode.drawBox
train
public function drawBox($x1, $y1, $z1, $x2, $y2, $z2) { $this->setCode("(box)"); $this->setCode("G0 X{$x1} Y{$y1} Z{$this->spindleAxisStartPosition} (move to spindle axis start position)"); $this->setCode("G1 Z{$z1}"); $this->setCode("G1 X{$x1} Y{$y1} Z{$z1}"); $this->setCode("G1 Y{$y2}"); $this->setCode("...
php
{ "resource": "" }
q7397
GCode.drawLine
train
public function drawLine($xStart, $yStart, $zStart, $xEnd, $yEnd, $zEnd) { $this->setCode("(line)"); $this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}"); $this->setCode("G1 Z{$zStart}"); // testing tool setup tool metric M8 diameter 4mm $this->setCode("T1 M08"); $this->setCode(...
php
{ "resource": "" }
q7398
GCode.drawCubicSpline
train
public function drawCubicSpline($xStart, $yStart, $xFromEnd, $yFromEnd, $xEnd, $yEnd) { $this->setCode("(cubic spline)"); $this->setCode("G0 X{$xStart} Y{$yStart} Z{$this->spindleAxisStartPosition}"); // $this->setCode("G1 Z{$zStart}"); // G5 Cubic spline $this->setCode("G5 I{$xStart} J{$yStart} P{$xFromEn...
php
{ "resource": "" }
q7399
Handler.createMessageCallback
train
protected function createMessageCallback(Recipient $user, $subject = null, $callback = null) { return function (Message $message) use ($user, $subject, $callback) { // Set the recipient detail. $message->to($user->getRecipientEmail(), $user->getRecipientName()); // Only ...
php
{ "resource": "" }