_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q5400 | DateController.syncCommand | train | public function syncCommand($url = 'http://www.baidu.com')
{
$timestamp = $this->_getRemoteTimestamp($url);
if ($timestamp === false) {
return $this->console->error(['fetch remote timestamp failed: `:url`', 'url' => $url]);
} else {
$this->_updateDate($timestamp);
... | php | {
"resource": ""
} |
q5401 | DateController.remoteCommand | train | public function remoteCommand($url = 'http://www.baidu.com')
{
$timestamp = $this->_getRemoteTimestamp($url);
if ($timestamp === false) {
return $this->console->error(['fetch remote timestamp failed: `:url`', 'url' => $url]);
} else {
$this->console->writeLn(date('Y-m... | php | {
"resource": ""
} |
q5402 | DateController.diffCommand | train | public function diffCommand($url = 'http://www.baidu.com')
{
$remote_ts = $this->_getRemoteTimestamp($url);
$local_ts = time();
if ($remote_ts === false) {
return $this->console->error(['fetch remote timestamp failed: `:url`', 'url' => $url]);
} else {
$this->... | php | {
"resource": ""
} |
q5403 | PluploadHandler._getRequestFile | train | private function _getRequestFile()
{
$data = [
'name' => $this->_fileName,
'size' => $this->_fileSize,
'tmp_name' => $this->_filePath
];
return new \Mmi\Http\RequestFile($data);
} | php | {
"resource": ""
} |
q5404 | TvheadendCommand.askQuestion | train | protected function askQuestion($question, $choices, $default)
{
// Ask until we get a valid response
do
{
echo $question.' '.$choices.': ';
$handle = fopen("php://stdin", "r");
$line = fgets($handle);
$response = trim($line);
// Use default when no response is given
if (empty($response))
... | php | {
"resource": ""
} |
q5405 | ApiKeyController.requestApiKeyAction | train | public function requestApiKeyAction(Request $request)
{
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
$dispatcher = $this->get('event_dispatcher');
$credentials = [];
if ($request->request->has('login')) {
$credentials[$this->getProp... | php | {
"resource": ""
} |
q5406 | ApiKeyController.removeSessionAction | train | public function removeSessionAction(Request $request)
{
/** @var \Doctrine\Common\Persistence\ObjectManager $om */
$om = $this->get($this->container->getParameter('ma27_api_key_authentication.object_manager'));
if (!$header = (string) $request->headers->get($this->container->getParameter('m... | php | {
"resource": ""
} |
q5407 | ApiKeyController.processAuthentication | train | private function processAuthentication(array $credentials)
{
/** @var \Ma27\ApiKeyAuthenticationBundle\Service\Auth\AuthenticationHandlerInterface $authenticationHandler */
$authenticationHandler = $this->get('ma27_api_key_authentication.auth_handler');
/** @var \Symfony\Component\EventDispa... | php | {
"resource": ""
} |
q5408 | OracleMetaDataDAO.hydrateDataObject | train | private function hydrateDataObject($data)
{
$dataObject = new MetadataDataObjectOracle(
new MetaDataColumnCollection(),
new MetaDataRelationCollection()
);
$tableName = $data['TABLE_NAME'];
$owner = $data['OWNER'];
$dataObject->setName($owner . '... | php | {
"resource": ""
} |
q5409 | MySQLMetaDataDAO.pdoMetadataToGeneratorMetadata | train | private function pdoMetadataToGeneratorMetadata(array $metadataCollection)
{
$metaDataCollection = new MetaDataCollection();
foreach ($metadataCollection as $tableName) {
$metaDataCollection->append(
$this->hydrateDataObject($tableName)
);
}
... | php | {
"resource": ""
} |
q5410 | MySQLMetaDataDAO.hydrateDataObject | train | private function hydrateDataObject($tableName, array $parentName = array())
{
$dataObject = new MetadataDataObjectMySQL(
new MetaDataColumnCollection(),
new MetaDataRelationCollection()
);
$dataObject->setName($tableName);
$statement = $this->pdo->prepare(
... | php | {
"resource": ""
} |
q5411 | Auth.authenticate | train | public static function authenticate($identity, $credential)
{
//błędna autoryzacja (brak aktywnego użytkownika)
if (null === $record = self::_findUserByIdentity($identity)) {
return;
}
//próby logowania lokalnie i ldap
if (!self::_localAuthenticate($record, $cred... | php | {
"resource": ""
} |
q5412 | Auth.idAuthenticate | train | public static function idAuthenticate($id)
{
//wyszukiwanie aktywnego użytkownika
if (null === $record = self::_findUserByIdentity($id)) {
return;
}
return self::_authSuccess($record);
} | php | {
"resource": ""
} |
q5413 | Auth._authSuccess | train | protected static function _authSuccess(CmsAuthRecord $record)
{
//zapis poprawnego logowania do rekordu
$record->lastIp = \Mmi\App\FrontController::getInstance()->getEnvironment()->remoteAddress;
$record->lastLog = date('Y-m-d H:i:s');
$record->save();
\Mmi\App\FrontControlle... | php | {
"resource": ""
} |
q5414 | ConnectorModel.importFileMeta | train | public function importFileMeta(array $files)
{
//iteracja po plikach (ta sama nazwa "name")
foreach ($files as $importData) {
//brak id
if (!isset($importData['name']) || !isset($importData['id'])) {
return;
}
//sprawdzanie istnienia pl... | php | {
"resource": ""
} |
q5415 | Client.decode | train | public function decode($json)
{
$decoded = json_decode($json, true);
if (null !== $decoded) {
return $decoded;
}
if (JSON_ERROR_NONE === json_last_error()) {
return $json;
}
return self::$json_errors[json_last_error()];
} | php | {
"resource": ""
} |
q5416 | CustomColumn.renderCell | train | public function renderCell(\Mmi\Orm\RecordRo $record)
{
$view = FrontController::getInstance()->getView();
$view->record = $record;
return $view->renderDirectly($this->getTemplateCode());
} | php | {
"resource": ""
} |
q5417 | SerializeHydrator.extract | train | public function extract(callable $callback = null)
{
if ($callback === null) {
$result = $this->result->serialize();
}
else {
$result = $callback($this->result->serialize());
}
return $result;
} | php | {
"resource": ""
} |
q5418 | PHPCompiler.set_conf | train | function set_conf( $confname ){
$this->confname = $confname;
$this->confdir = PLUG_HOST_DIR.'/'.$confname;
if( ! PLUGTool::check_dir($this->confdir) ){
throw new PLUGException('bad conf');
}
// parse default plug conf using external parser
$confpath = $this->confdir.'/PLUG.conf.php';
$this->conf_vars =... | php | {
"resource": ""
} |
q5419 | PHPCompiler.load_conf | train | function load_conf( $confpath ){
if( ! PLUGTool::check_file($confpath) ){
throw new PLUGException('bad conf');
}
$e = PLUG::exec_bin( 'parseconf', array($confpath), $s );
if( $e ){
trigger_error('Failed to parse '.basename($confpath), E_USER_NOTICE );
return false;
}
$a = unserialize( $s );
if( !... | php | {
"resource": ""
} |
q5420 | PHPCompiler.register_include | train | function register_include( $path ){
if( ! isset($this->incs[$path]) ){
$this->incs[$path] = 1;
return false;
}
else {
$this->incs[$path]++;
return true;
}
} | php | {
"resource": ""
} |
q5421 | PHPCompiler.next_dependency | train | function next_dependency(){
foreach( $this->dependencies as $path => $done ){
if( ! $done ){
$this->dependencies[$path] = 1;
return $path;
}
}
// none
return null;
} | php | {
"resource": ""
} |
q5422 | PHPCompiler.open_php | train | private function open_php( &$src ){
if( ! $this->inphp ){
$this->inphp = true;
// this may result in back to back tags, which we can avoid with a bit of string manipulation.
$makenice = $this->opt(COMPILER_OPTION_NICE_TAGS);
if( $makenice && substr( $src, -2 ) === '?>' ){
// trim trailing clos... | php | {
"resource": ""
} |
q5423 | PHPCompiler.close_php | train | private function close_php( &$src ){
if( $this->inphp ){
$this->inphp = false;
// this may result in back to back tags, which we can avoid with a bit of string manipulation.
$makenice = $this->opt(COMPILER_OPTION_NICE_TAGS);
if( $makenice && substr( $src, -5 ) === '<?php' ){
// trim trailing o... | php | {
"resource": ""
} |
q5424 | PLUGSessionObject.session_lifespan | train | function session_lifespan( $ttl = null, $hibernate = null ){
$current = $this->sess_ttl;
if( $ttl !== null ){
$this->sess_ttl = $ttl;
}
if( $hibernate !== null ){
$this->sess_hibernate = $hibernate;
}
return $current;
} | php | {
"resource": ""
} |
q5425 | PLUG.raise_error | train | static function raise_error( $code, $message, $type, array $trace = null ){
if( error_reporting() === 0 ){
// suppressed with `@' operator
return;
}
self::clear_error_handlers();
if( is_null($trace) ){
$trace = debug_backtrace();
array_shift( $trace );
}
$callee = current( $trace );
$Err = ne... | php | {
"resource": ""
} |
q5426 | PLUG.raise_exception | train | static function raise_exception( Exception $Ex, $type ){
if( error_reporting() === 0 ){
// suppressed with `@' operator
return;
}
PLUG::clear_error_handlers();
$code = $Ex->getCode() or $code = PLUG_EXCEPTION_STD;
$Err = new PLUGError( $code, $type, $Ex->getMessage(), $Ex->getFile(), $Ex->getLine(), $Ex... | php | {
"resource": ""
} |
q5427 | PLUG.dump_errors | train | static function dump_errors( $emask = PLUG_ERROR_REPORTING ){
$errs = PLUGError::get_errors( $emask );
foreach( $errs as $Err ){
$s = $Err->__toString(). "\n";
if( PLUG_CLI ){
PLUGCli::stderr( $s );
}
else {
echo $s;
}
}
} | php | {
"resource": ""
} |
q5428 | PLUG.set_error_display | train | static function set_error_display( $handler ){
if( ! is_callable($handler) ){
trigger_error( 'Error display handler is not callable ('.var_export($handler,1).')', E_USER_WARNING );
return false;
}
PLUGError::$displayfunc = $handler;
return true;
} | php | {
"resource": ""
} |
q5429 | PLUG.set_error_logger | train | static function set_error_logger( $handler ){
if( ! is_callable($handler) ){
trigger_error( 'Error logging handler is not callable ('.var_export($handler,1).')', E_USER_WARNING );
return false;
}
PLUGError::$logfunc = $handler;
return true;
} | php | {
"resource": ""
} |
q5430 | PLUG.set_error_terminator | train | static function set_error_terminator( $handler ){
if( ! is_callable($handler) ){
trigger_error( 'Fatal error handler is not callable ('.var_export($handler,1).')', E_USER_WARNING );
return false;
}
PLUGError::$deathfunc = $handler;
return true;
} | php | {
"resource": ""
} |
q5431 | UpdateLastActionFieldListener.onFirewallLogin | train | public function onFirewallLogin(OnFirewallAuthenticationEvent $event)
{
$this->doModify($event);
$this->om->persist($event->getUser());
$this->om->flush();
} | php | {
"resource": ""
} |
q5432 | UpdateLastActionFieldListener.doModify | train | private function doModify(AbstractUserEvent $event)
{
$this->classMetadata->modifyProperty(
$event->getUser(),
new \DateTime(sprintf('@%s', $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'))),
ClassMetadata::LAST_ACTION_PROPERTY
);
} | php | {
"resource": ""
} |
q5433 | Acl.setupAcl | train | public static function setupAcl()
{
$acl = new \Mmi\Security\Acl;
$aclData = (new CmsAclQuery)
->join('cms_role')->on('cms_role_id')
->find();
foreach ($aclData as $aclRule) { /* @var $aclData \Cms\Orm\CmsAclRecord */
$resource = '';
if ($aclRu... | php | {
"resource": ""
} |
q5434 | Log.create | train | public function create($userId=null, $eventLog=null, $eventData=null)
{
if(is_null($userId)) throw new \Exception('User ID is required.');
if(is_null($eventLog)) throw new \Exception('Event Log is required.');
if(!is_numeric($userId)) throw new \Exception("Invalid User ID.");
$id = ... | php | {
"resource": ""
} |
q5435 | AnnotatedRouteControllerLoader.configureRoute | train | protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
{
parent::configureRoute($route, $class, $method, $annot);
if(is_a($annot, 'FOM\ManagerBundle\Configuration\Route')) {
$route->setPath($this->prefix . $route->getPath());
}... | php | {
"resource": ""
} |
q5436 | PayPayWebservice.checkIntegrationState | train | public function checkIntegrationState()
{
$this->response = parent::checkIntegrationState($this->entity);
/**
* Checks the state of the platform integration.
*/
if (Exception\IntegrationState::check($this->response)) {
throw new Exception\IntegrationState($this... | php | {
"resource": ""
} |
q5437 | PayPayWebservice.subscribeToWebhook | train | public function subscribeToWebhook(Structure\RequestWebhook $requestWebhook)
{
$this->response = parent::subscribeToWebhook($this->entity, $requestWebhook);
/**
* Checks the state of the platform integration.
*/
if (Exception\IntegrationState::check($this->response->integr... | php | {
"resource": ""
} |
q5438 | PayPayWebservice.createPaymentReference | train | public function createPaymentReference(Structure\RequestReferenceDetails $paymentData)
{
$this->response = parent::createPaymentReference($this->entity, $paymentData);
/**
* Checks the state of the platform integration.
*/
if (Exception\IntegrationState::check($this->respo... | php | {
"resource": ""
} |
q5439 | PayPayWebservice.validatePaymentReference | train | public function validatePaymentReference(Structure\RequestReferenceDetails $paymentData)
{
$this->response = parent::validatePaymentReference($this->entity, $paymentData);
/**
* Checks the state of the platform integration.
*/
if (Exception\IntegrationState::check($this->r... | php | {
"resource": ""
} |
q5440 | PayPayWebservice.doWebPayment | train | public function doWebPayment($requestWebPayment)
{
$this->response = parent::doWebPayment($this->entity, $requestWebPayment);
/**
* Checks the state of the platform integration.
*/
if (Exception\IntegrationState::check($this->response->requestState)) {
throw ne... | php | {
"resource": ""
} |
q5441 | PayPayWebservice.checkWebPayment | train | public function checkWebPayment($token, $transactionId)
{
$requestPayment = new Structure\RequestPaymentDetails($token, $transactionId);
$this->response = parent::checkWebPayment($this->entity, $requestPayment);
/**
* Checks the state of the platform integration.
*/
... | php | {
"resource": ""
} |
q5442 | PayPayWebservice.getEntityPayments | train | public function getEntityPayments($startDate, $endDate)
{
$requestInterval = new Structure\RequestInterval($startDate, $endDate);
$this->response = parent::getEntityPayments($this->entity, $requestInterval);
/**
* Checks the state of the platform integration.
*/
i... | php | {
"resource": ""
} |
q5443 | PayPayWebservice.checkEntityPayments | train | public function checkEntityPayments($payments = array())
{
$requestReferenceDetails = new Structure\RequestEntityPayments();
if ($payments) {
foreach ($payments as $key => $value) {
$requestPayment = new Structure\RequestReferenceDetails($value);
$requestR... | php | {
"resource": ""
} |
q5444 | ZendFramework2Environnement.getDependence | train | public static function getDependence(FileManager $fileManager)
{
if (null === self::$serviceManager) {
$config = self::findConfigFile($fileManager);
try {
self::$serviceManager = Application::init(
$fileManager->includeFile($config)
... | php | {
"resource": ""
} |
q5445 | LRStation.collect_non_deterministic | train | function collect_non_deterministic( Grammar $Grammar, $k ){
// avoid recursion by testing if already collected
if ( isset($this->etransitions) ){
return;
}
$this->etransitions = array();
// get all rules with our non-terminal as left had side
foreach( $Grammar->get_rules($this->nt) as $r => $rule )... | php | {
"resource": ""
} |
q5446 | LRStation.collect_states | train | function collect_states( Grammar $Grammar ){
$states = array();
// start recursion
$this->collect_states_recursive( $states, $Grammar, array(), ++self::$threadInc );
return $states;
} | php | {
"resource": ""
} |
q5447 | LRStation.make | train | static function make( $nt, $la = null ){
if( isset(self::$uindex[$nt][$la]) ){
return self::$uindex[$nt][$la];
}
return new LRStation( $nt, $la );
} | php | {
"resource": ""
} |
q5448 | LRStation.get | train | static function get( $nt, $la = null ){
if( isset(self::$uindex[$nt][$la]) ){
return self::$uindex[$nt][$la];
}
return null;
} | php | {
"resource": ""
} |
q5449 | IncStatementNode.get_args | train | function get_args( array $consts, array $vars ){
$args = array();
// limit depth of search to avoid collecting nested func calls
$argnodes = $this->get_nodes_by_symbol( NT_ARG, 3 );
foreach( $argnodes as $i => $arg ){
$args[] = $arg->compile_string( $consts, $vars );
}
return $args;
} | php | {
"resource": ""
} |
q5450 | HistoryFactory.getInstance | train | public static function getInstance(ContextInterface $context)
{
$fileManager = new FileManager();
$historyHydrator = HistoryHydratorFactory::getInstance($context);
return new HistoryManager($fileManager, $historyHydrator);
} | php | {
"resource": ""
} |
q5451 | GrammarBuilder.make | train | static function make( array $grammar, $class = __CLASS__ ){
$Me = new $class;
foreach( $grammar as $nt => $rhss ){
foreach( $rhss as $rhs ){
$Me->make_rule( $nt, $rhs );
}
}
return $Me;
} | php | {
"resource": ""
} |
q5452 | GrammarBuilder.rule_signature | train | private static function rule_signature( $lhs, array $rhs ){
$a[] = $lhs;
foreach( $rhs as $t ){
$a[] = $t;
}
return implode( '.', $a );
} | php | {
"resource": ""
} |
q5453 | GrammarBuilder.make_rule | train | function make_rule( $nt, array $rhs ){
if( ! isset($this->uindex) || ! isset($this->ntindex) ){
$this->rebuild_index();
}
// explicit goal rule ??
if( end($rhs) === P_EOF ){
// trigger_error("Do not specify P_EOF explicitly in grammar", E_USER_WARNING );
$this->goal = $nt;
$this->rules[ -2 ] =... | php | {
"resource": ""
} |
q5454 | GrammarBuilder.remove_rules | train | function remove_rules( $nt ){
if( ! isset($this->ntindex) ){
$this->rebuild_index();
}
// remove this non-terminal's rules
if( isset($this->ntindex[$nt]) ){
foreach( $this->ntindex[$nt] as $i ){
$sig = self::rule_signature( $nt, $this->rules[$i][1] );
unset( $this->rules[$i] );
unset( $this->... | php | {
"resource": ""
} |
q5455 | GrammarBuilder.build_first_sets | train | private function build_first_sets(){
$firsts = array();
do {
$changes = 0;
foreach( $this->rules as $rule ){
list( $nt, $rhs ) = $rule;
$s = reset( $rhs );
// get any special rule processing for this non-terminal
//$excludela = isset($this->excludela[$nt]) ? $this->excludela[$nt] : null;
d... | php | {
"resource": ""
} |
q5456 | GrammarBuilder.build_follow_sets | train | private function build_follow_sets(){
if( ! isset($this->firsts) ){
$this->firsts = $this->build_first_sets();
}
// remember inhritance for error checking
//$inherits = array();
// create default/dummy sets with special symbols
$follows = array(
P_GOAL => array(),
P_EOF => array()
);
do {
$c... | php | {
"resource": ""
} |
q5457 | JsonHydrator.extract | train | public function extract(callable $callback = null)
{
$this->response = Di::getDefault()->get('response');
if ($callback === null) {
$this->response->setContent(json_encode($this->result->toArray()));
}
else {
$this->response->setContent($callback(
... | php | {
"resource": ""
} |
q5458 | IsEventSubscriberConstraint.matches | train | protected function matches($other): bool
{
$this->resetProblems();
if (!($other instanceof EventSubscriberInterface)) {
$this->addProblem('Subscriber must implement \Symfony\Component\EventDispatcher\EventSubscriberInterface.');
return false;
}
$subscribedEven... | php | {
"resource": ""
} |
q5459 | IsEventSubscriberConstraint.checkListener | train | protected function checkListener(EventSubscriberInterface $subscriber, $event, $listener)
{
if (is_string($listener)) {
// Add the default priority and use the default validation.
$listener = array($listener, 0);
}
if (!is_array($listener)) {
$this->addPro... | php | {
"resource": ""
} |
q5460 | IsEventSubscriberConstraint.checkMethod | train | protected function checkMethod($subscriber, $event, $method)
{
if (!is_string($method)) {
$message = 'Listener definition for event "%s" contains an invalid method reference: %s';
$this->addProblem(sprintf($message, $event, $this->exporter->export($method)));
return;
... | php | {
"resource": ""
} |
q5461 | IsEventSubscriberConstraint.checkPriority | train | protected function checkPriority($event, $priority)
{
if (!is_int($priority)) {
$message = 'Priority for event "%s" must be an integer, but received: %s';
$this->addProblem(sprintf($message, $event, $this->exporter->export($priority)));
return;
}
} | php | {
"resource": ""
} |
q5462 | ControllerPolicyMiddleware.isIgnoredDomain | train | public function isIgnoredDomain($domain)
{
if ($ignoreRegexes = $this->config()->get('ignore_domain_regexes')) {
foreach ($ignoreRegexes as $ignore) {
if (preg_match($ignore, $domain) > 0) {
return true;
}
}
}
retur... | php | {
"resource": ""
} |
q5463 | ControllerPolicyMiddleware.process | train | public function process(HTTPRequest $request, callable $delegate)
{
/** @var HTTPResponse $response */
$response = $delegate($request);
// Ignore by regexes.
if ($this->shouldCheckHttpHost() && $this->isIgnoredDomain($_SERVER['HTTP_HOST'])) {
return $response;
}
... | php | {
"resource": ""
} |
q5464 | Direct._message | train | public function _message($type, $message)
{
$context = $this->_context;
$cssClasses = isset($this->_cssClasses[$type]) ? $this->_cssClasses[$type] : '';
$context->messages[] = '<div class="' . $cssClasses . '">' . $message . '</div>' . PHP_EOL;
} | php | {
"resource": ""
} |
q5465 | CategoryAclModel._updateAcl | train | protected function _updateAcl(\Cms\Orm\CmsCategoryAclRecord $aclRecord)
{
//iteracja po identyfikatorach kategorii
foreach ($this->_getChildrenCategoryIds($aclRecord->cmsCategoryId) as $categoryId) {
//dozwalanie lub zabranianie w ACL
$aclRecord->access == 'allow' ?
... | php | {
"resource": ""
} |
q5466 | PLUGTool.import_php | train | static function import_php( $package, $silent = false ){
$type = current( explode('.', $package) );
$paths = self::collect_package( $package, 'php', $silent, 'conf' );
if( !$silent && empty($paths) ){
trigger_error("Bad import `$package'", E_USER_ERROR );
}
foreach( $paths as $cname => $path ){
... | php | {
"resource": ""
} |
q5467 | PLUGTool.collect_package | train | static function collect_package( $package, $ext, $silent, $confname ){
// get from cache for speed
$cachekey = $package.'.'.$ext;
if( isset(self::$dircache[$cachekey]) ){
return self::$dircache[$cachekey];
}
$apath = explode( '.', $package );
$type = $apath[0]; // e.g. "PLUG"
$cname = array_pop(... | php | {
"resource": ""
} |
q5468 | PLUGTool.collect_files | train | static function collect_files( $dpath, $r = false, $match = null, $ignore = null ){
$paths = array();
$dhandle = opendir( $dpath );
while( $f = readdir($dhandle) ){
if( $f === '.' || $f === '..' ){
continue;
}
// pattern tested only on file name
// ignore pattern applies to directories as well as ... | php | {
"resource": ""
} |
q5469 | PLUGTool.check_file | train | static function check_file( $path, $w = false, $isdir = false ){
$strtype = $isdir ? 'Directory' : 'File';
if( !file_exists($path) ){
trigger_error("$strtype not found; `$path'", E_USER_NOTICE );
return false;
}
if( $isdir && !is_dir($path) ){
trigger_error("Not a directory; `$path'", E_USER_NOTICE )... | php | {
"resource": ""
} |
q5470 | PLUGTool.map_deployment_virtual | train | static function map_deployment_virtual( $path ){
// if path is outside document root move to special plug include dir
if( strpos( $path, PLUG_VIRTUAL_DIR ) !== 0 ){
if( strpos( $path, PLUG_HOST_DIR ) === 0 ){
// is under host root
$len = strlen(PLUG_HOST_DIR) + 1;
$subpath = substr_replace( $path, '... | php | {
"resource": ""
} |
q5471 | AttributeValueRelationModel.getRelationFiles | train | public function getRelationFiles()
{
$filesByObject = new \Mmi\Orm\RecordCollection;
//wyszukiwanie wartości
foreach ($this->getAttributeValues() as $record) {
//pobieranie klucza atrybutu (w celu zgrupowania)
if ($record->getJoined('cms_attribute_type')->uploader) {
... | php | {
"resource": ""
} |
q5472 | ExportResponse.setCsv | train | public function setCsv(array &$data, $detectHead = true)
{
$handle = self::createMemoryHandle();
if($detectHead && count($data)> 0){
fputcsv($handle, array_keys($data[0]), $this->delimiter, $this->enclosure);
}
foreach ($data as $row) {
fputcsv($han... | php | {
"resource": ""
} |
q5473 | ExportResponse.setType | train | public function setType($type)
{
switch ($type) {
case self::TYPE_CSV:
$this->headers->add(array('Content-Type' => 'text/csv;charset=' . self::UTF_16_LE));
break;
case self::TYPE_XLS:
$this->headers->add(array("Content-Type" => "... | php | {
"resource": ""
} |
q5474 | ExportResponse.setFileName | train | public function setFileName($fileName)
{
$this->fileName = $fileName;
$this->headers->add(array('Content-Disposition' => 'attachment; filename="' . $this->fileName . '"'));
return $this;
} | php | {
"resource": ""
} |
q5475 | BNFRulesNode.collect_symbols | train | function collect_symbols(){
if( ! $this->length ){
return null;
}
$Rule = $this->reset();
do {
if( $Rule->length !== 6 ){
// empty rule most likely
continue;
}
// collect rule name - guaranteed to be nontermainal
$Name = $Rule->get_child( 1 );
$n = $Name->evaluate();
$nts[ $n ] = $n... | php | {
"resource": ""
} |
q5476 | BNFRulesNode.make_lex | train | function make_lex( $i = 0 ){
$Lex = new LexBuilder( $i );
foreach( $this->collect_symbols() as $symbols ){
foreach( $symbols as $t => $s ){
if( preg_match('/^\W/', $s, $r ) ){
$Lex->define_literal( (string) $t );
}
else if( $Lex->defined($s) ){
}
else if( defined($s) ){
$Lex->redefi... | php | {
"resource": ""
} |
q5477 | View.setVar | train | public function setVar($name, $value)
{
$context = $this->_context;
$context->vars[$name] = $value;
return $this;
} | php | {
"resource": ""
} |
q5478 | View.setVars | train | public function setVars($vars)
{
$context = $this->_context;
$context->vars = array_merge($context->vars, $vars);
return $this;
} | php | {
"resource": ""
} |
q5479 | View.getVar | train | public function getVar($name = null)
{
$context = $this->_context;
if ($name === null) {
return $context->vars;
} else {
return isset($context->vars[$name]) ? $context->vars[$name] : null;
}
} | php | {
"resource": ""
} |
q5480 | View.render | train | public function render($template = null, $vars = null)
{
$context = $this->_context;
if ($vars !== null) {
$context->vars = $vars;
}
if (!$template) {
$area = $this->dispatcher->getArea();
$controller = $this->dispatcher->getController();
... | php | {
"resource": ""
} |
q5481 | JbConfigKnpMenuExtension.parseFile | train | public function parseFile($file)
{
$bundleConfig = Yaml::parse(file_get_contents(realpath($file)));
if (!is_array($bundleConfig)) {
return array();
}
return $bundleConfig;
} | php | {
"resource": ""
} |
q5482 | GeneratorFinderFactory.getInstance | train | public static function getInstance()
{
return new GeneratorFinderCache(
new GeneratorFinder(
TranstyperFactory::getInstance(),
GeneratorValidatorFactory::getInstance(),
new FileManager()
),
Installer::getDirectories(),
... | php | {
"resource": ""
} |
q5483 | Route._compilePattern | train | protected function _compilePattern($pattern)
{
if (strpos($pattern, '{') !== false) {
$tr = [
'{area}' => '{area:[a-z]\w*}',
'{controller}' => '{controller:[a-z]\w*}',
'{action}' => '{action:[a-z]\w*}',
'{params}' => '{params:.*}',
... | php | {
"resource": ""
} |
q5484 | ClassMetadataPropertiesCacheWarmer.buildCacheData | train | private function buildCacheData()
{
$metadata = $this->driver->getMetadataForUser();
return serialize(
array_map(function (\ReflectionProperty $property) {
return $property->getName();
}, $metadata)
);
} | php | {
"resource": ""
} |
q5485 | Generator.addBuilder | train | public function addBuilder(BuilderInterface $builder)
{
$builder->setGenerator($this);
$builder->setTemplateDirs($this->templateDirectories);
$builder->setMustOverwriteIfExists($this->mustOverwriteIfExists);
$builder->setVariables(array_merge($this->variables, $builder->getVariables(... | php | {
"resource": ""
} |
q5486 | TextCat.createLM | train | public function createLM( $text, $maxNgrams ) {
$ngram = [];
foreach ( preg_split( "/[{$this->wordSeparator}]+/u", $text ) as $word ) {
if ( empty( $word ) ) {
continue;
}
$word = "_" . $word . "_";
$len = mb_strlen( $word, "UTF-8" );
for ( $i = 0; $i < $len; $i++ ) {
$rlen = $len - $i;
i... | php | {
"resource": ""
} |
q5487 | TextCat.writeLanguageFile | train | public function writeLanguageFile( $ngrams, $outfile ) {
$out = fopen( $outfile, "w" );
// write original array as "$ngrams"
fwrite( $out, '<?php $ngrams = ' . var_export( $ngrams, true ) . ";\n" );
// write reduced array as "$ranks"
$rank = 1;
$ranks = array_map( function ( $x ) use ( &$rank ) {
return ... | php | {
"resource": ""
} |
q5488 | TextCat.classify | train | public function classify( $text, $candidates = null ) {
$results = [];
$this->resultStatus = '';
// strip non-word characters before checking for min length, don't assess empty strings
$wordLength = mb_strlen( preg_replace( "/[{$this->wordSeparator}]+/", "", $text ) );
if ( $wordLength < $this->minInputLengt... | php | {
"resource": ""
} |
q5489 | AuthenticationPostListener.findAccessToken | train | private function findAccessToken(array $identity)
{
$config = $this->container->get('config');
foreach ($config['zf-oauth2-doctrine'] as $oauth2Config) {
if (array_key_exists('object_manager', $oauth2Config)) {
$objectManager = $this->container->get($oauth2Config['object... | php | {
"resource": ""
} |
q5490 | ProductControllerFeaturesExtension.GroupedFeatures | train | public function GroupedFeatures($showungrouped = false)
{
$features = $this->owner->Features()
->innerJoin("Feature","Feature.ID = ProductFeatureValue.FeatureID");
//figure out feature groups
$groupids = FeatureGroup::get()
->innerJoin("Feature","Feature.GroupID ... | php | {
"resource": ""
} |
q5491 | BNFParser.parse_string | train | static function parse_string( $s ){
if( $s == '' ){
throw new Exception('Cannot parse empty string');
}
// instantiate self
$Parser = new BNFParser;
// perform external tokenizing on string input
$tokens = bnf_tokenize( $s );
return $Parser->parse( $tokens );
} | php | {
"resource": ""
} |
q5492 | BNFParser.parse_file | train | static function parse_file( $f ){
$src = file_get_contents( $f, true );
if( $src === false ){
throw new Exception("Cannot read file $f");
}
return self::parse_string( $src );
} | php | {
"resource": ""
} |
q5493 | Db.fetchOne | train | public function fetchOne($sql, $bind = [], $fetchMode = \PDO::FETCH_ASSOC, $useMaster = false)
{
return ($rs = $this->fetchAll($sql, $bind, $fetchMode, $useMaster)) ? $rs[0] : false;
} | php | {
"resource": ""
} |
q5494 | Db.fetchAll | train | public function fetchAll($sql, $bind = [], $fetchMode = \PDO::FETCH_ASSOC, $useMaster = false)
{
$context = $this->_context;
$context->sql = $sql;
$context->bind = $bind;
$context->affected_rows = 0;
$this->eventsManager->fireEvent('db:beforeQuery', $this);
if ($co... | php | {
"resource": ""
} |
q5495 | Db.delete | train | public function delete($table, $conditions, $bind = [])
{
if (is_string($conditions)) {
$conditions = [$conditions];
}
$wheres = [];
/** @noinspection ForeachSourceInspection */
foreach ($conditions as $k => $v) {
if (is_int($k)) {
$wh... | php | {
"resource": ""
} |
q5496 | Db.getEmulatedSQL | train | public function getEmulatedSQL($preservedStrLength = -1)
{
$context = $this->_context;
if (!$context->bind) {
return (string)$context->sql;
}
$bind = $context->bind;
if (isset($bind[0])) {
return (string)$context->sql;
} else {
$r... | php | {
"resource": ""
} |
q5497 | Db.begin | train | public function begin()
{
$context = $this->_context;
$this->logger->info('transaction begin', 'db.transaction.begin');
if ($context->transaction_level === 0) {
$this->eventsManager->fireEvent('db:beginTransaction', $this);
try {
$connection = $this... | php | {
"resource": ""
} |
q5498 | Db.rollback | train | public function rollback()
{
$context = $this->_context;
if ($context->transaction_level > 0) {
$this->logger->info('transaction rollback', 'db.transaction.rollback');
$context->transaction_level--;
if ($context->transaction_level === 0) {
$this-... | php | {
"resource": ""
} |
q5499 | CategoryModel.getCategoryTree | train | public function getCategoryTree($parentCategoryId = null)
{
//brak zdefiniowanej kategorii
if ($parentCategoryId === null) {
return $this->_categoryTree;
}
//wyszukiwanie kategorii
return $this->_searchChildren($this->_categoryTree, $parentCategoryId);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.