_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q263600 | CFDIFactory.newPostValidator | test | public function newPostValidator(): PostValidator
{
$postvalidator = new PostValidator();
$postvalidator->validators->append(new Validators\TFDVersions());
$postvalidator->validators->append(new Validators\Impuestos());
$postvalidator->validators->append(new Validators\Fechas());
$postvalidator->validators->append(new Validators\Conceptos());
$postvalidator->validators->append(new Validators\Totales());
$postvalidator->validators->append($this->newCertificadoValidator());
return $postvalidator;
} | php | {
"resource": ""
} |
q263601 | CFDIFactory.newRetriever | test | public function newRetriever(DownloaderInterface $downloader = null)
{
$localResourcesPath = $this->getLocalResourcesPath();
if ('' === $localResourcesPath) {
return null;
}
return new XsdRetriever($localResourcesPath, $downloader);
} | php | {
"resource": ""
} |
q263602 | CFDIFactory.newXsltRetriever | test | public function newXsltRetriever(DownloaderInterface $downloader = null)
{
$localResourcesPath = $this->getLocalResourcesPath();
if ('' === $localResourcesPath) {
return null;
}
return new XsltRetriever($localResourcesPath, $downloader);
} | php | {
"resource": ""
} |
q263603 | CFDIFactory.newCertificadoValidator | test | public function newCertificadoValidator(): CertificadoValidator
{
$validator = new CertificadoValidator();
$validator->setCadenaOrigen($this->newCadenaOrigen());
$validator->setXsltRetriever($this->newXsltRetriever());
return $validator;
} | php | {
"resource": ""
} |
q263604 | CFDIFactory.newCFDIReader | test | public function newCFDIReader(
string $content,
array &$errors = [],
array &$warnings = [],
bool $requireTimbre = true
): CFDIReader {
// before creation
$schemaValidator = $this->newSchemasValidator();
$schemaValidator->validate($content);
// creation
$cfdireader = new CFDIReader($content, $requireTimbre);
// after creation
$postValidator = $this->newPostValidator();
$postValidator->validate($cfdireader);
$errors = $postValidator->issues->messages(PostValidations\IssuesTypes::ERROR)->all();
$warnings = $postValidator->issues->messages(PostValidations\IssuesTypes::WARNING)->all();
return $cfdireader;
} | php | {
"resource": ""
} |
q263605 | CommandBus.handle | test | public function handle(CommandInterface $command)
{
if (!$commandHandler = $this->handlerResolver->resolve($command)) {
throw new HandlerNotFoundException();
}
$commandHandler->handle($command);
} | php | {
"resource": ""
} |
q263606 | Cookies.set | test | public function set($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
{
$expire = ($minutes == 0) ? 0 : time() + ($minutes * 60);
$cookie = new Cookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
$this->cookies[$name] = $cookie;
return $this;
} | php | {
"resource": ""
} |
q263607 | Cookies.get | test | public function get($name, $default = null)
{
if (null !== ($value = $this->request->cookies->get($name))) {
return $value ?: $default;
}
return $default;
} | php | {
"resource": ""
} |
q263608 | Arr.firstBy | test | public static function firstBy(array $array, Closure $closure)
{
foreach ($array as $key => $value) {
if (true === call_user_func_array($closure, array($key, $value))) {
return $value;
}
}
return null;
} | php | {
"resource": ""
} |
q263609 | BCryptPasswordEncoder.isPasswordValid | test | public function isPasswordValid($encodedPassword, $rawPassword, $salt)
{
return ! $this->isPasswordTooLong($rawPassword) && password_verify($rawPassword, $encodedPassword);
} | php | {
"resource": ""
} |
q263610 | CFDIReader.node | test | public function node(...$nodePath)
{
$node = $this->retrieveNode(...$nodePath);
return (null === $node) ? null : clone $node;
} | php | {
"resource": ""
} |
q263611 | CFDIReader.attribute | test | public function attribute(string ...$nodePath): string
{
// cast to string since array_pop can return NULL
$attribute = (string) array_pop($nodePath);
$node = $this->retrieveNode(...$nodePath);
return (null !== $node) ? (string) $node[$attribute] : '';
} | php | {
"resource": ""
} |
q263612 | CFDIReader.appendChild | test | private function appendChild(SimpleXMLElement $source, SimpleXMLElement $parent, array $nss): SimpleXMLElement
{
$new = $parent->addChild($this->normalizeName($source->getName()), (string) $source);
$this->populateNode($source, $new, $nss);
return $new;
} | php | {
"resource": ""
} |
q263613 | CFDIReader.populateNode | test | private function populateNode(SimpleXMLElement $source, SimpleXMLElement $destination, array $nss)
{
// populate attributes
foreach ($nss as $ns) {
foreach ($source->attributes($ns) as $attribute) {
/* @var $attribute SimpleXMLElement */
$destination->addAttribute($this->normalizeName($attribute->getName()), (string) $attribute);
}
}
// populate children
foreach ($nss as $ns) {
foreach ($source->children($ns) as $child) {
$this->appendChild($child, $destination, $nss);
}
}
} | php | {
"resource": ""
} |
q263614 | CFDIReader.retrieveNode | test | private function retrieveNode(string ...$nodePath)
{
$node = $this->comprobante;
foreach ($nodePath as $level) {
if (! isset($node->{$level})) {
return null;
}
$node = $node->{$level};
}
return $node;
} | php | {
"resource": ""
} |
q263615 | AbstractRequired.hasRequiredValue | test | protected function hasRequiredValue($value)
{
$valid = true;
// $_FILES
if ($value instanceof UploadedFile && !$value->isValid()) {
$valid = false;
}
// Null
else if (is_null($value)) {
$valid = false;
}
// String
else if ((is_string($value) && trim($value) === '')) {
$valid = false;
}
// Array
else if((is_array($value) && !$value)) {
$valid = false;
}
return $valid;
} | php | {
"resource": ""
} |
q263616 | Profiler.addDoctrineQueries | test | public function addDoctrineQueries(DebugStack $debugStack)
{
foreach ($debugStack->queries as $query) {
if (!$query['params']) {
$query['params'] = array();
}
if (!$query['types']) {
$query['types'] = array();
}
// Because doctrine columns can be more advanced we need to convert them to string
// This is a quick a dirty way of doing it so could do with going elsewhere
$query['params'] = $this->convertDoctrineParameters($query['params'], $query['types']);
$queries = array(
array(
'query' => $query['sql'],
'bindings' => $query['params'],
'time' => $query['executionMS'],
)
);
$this->addQueries($queries);
}
return $this;
} | php | {
"resource": ""
} |
q263617 | Profiler.addTimers | test | public function addTimers($timers = array())
{
foreach ($timers as $name => $timer) {
$this->timers[$name] = $timer;
}
return $this;
} | php | {
"resource": ""
} |
q263618 | Profiler.getFileSize | test | protected function getFileSize($size)
{
$units = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$units[$i];
} | php | {
"resource": ""
} |
q263619 | Validators.append | test | public function append(ValidatorInterface $validator)
{
if (false === $this->getIndex($validator)) {
$this->validators[] = $validator;
}
} | php | {
"resource": ""
} |
q263620 | Validators.remove | test | public function remove(ValidatorInterface $validator)
{
$index = $this->getIndex($validator);
if (false !== $index) {
unset($this->validators[$index]);
$this->validators = array_values($this->validators);
}
} | php | {
"resource": ""
} |
q263621 | Validators.get | test | public function get($index)
{
if (! array_key_exists($index, $this->validators)) {
throw new \OutOfBoundsException('Validator does not exists');
}
return $this->validators[$index];
} | php | {
"resource": ""
} |
q263622 | Validate.make | test | public static function make(array $arguments): self
{
if (! count($arguments)) {
throw new \InvalidArgumentException('Cannot construct without arguments');
}
$script = array_shift($arguments);
$filenames = [];
$localPath = null;
while (null !== $argument = array_shift($arguments)) {
if (in_array($argument, ['--local-path', '-l'])) {
$localPath = (count($arguments)) ? array_shift($arguments) : '';
continue;
}
if (false === strpos($argument, '-')) {
$filenames[] = $argument;
continue;
}
throw new \InvalidArgumentException("Invalid argument '$argument'");
}
$command = new self($script, $filenames);
$command->localPath = (null !== $localPath && 'disable' === $localPath) ? '' : $localPath;
return $command;
} | php | {
"resource": ""
} |
q263623 | Validate.run | test | public function run()
{
$factory = new CFDIFactory($this->localPath);
foreach ($this->filenames as $filename) {
$this->runFilename($factory, $filename);
}
} | php | {
"resource": ""
} |
q263624 | Validate.runFilename | test | protected function runFilename(CFDIFactory $factory, string $argument)
{
if ('' === $argument) {
$this->error('FATAL: Empty filename');
return;
}
$filename = realpath($argument);
if ('' === $filename || ! is_file($filename) || ! is_readable($filename)) {
$this->error("File $argument FATAL: not found or is not readable");
return;
}
// do the object creation
try {
$errors = [];
$warnings = [];
$reader = $factory->newCFDIReader(file_get_contents($filename), $errors, $warnings);
foreach ($errors as $message) {
$this->error("File $argument ERROR: $message");
}
foreach ($warnings as $message) {
$this->error("File $argument WARNING: $message");
}
$this->write("File $argument UUID: " . $reader->getUUID());
} catch (\Exception $ex) {
$this->error("File $argument FATAL: " . $ex->getMessage());
}
} | php | {
"resource": ""
} |
q263625 | AuthenticationProvider.authorize | test | public function authorize(CredentialsInterface $credentials)
{
// Check if user can be found
if ( ! $user = $this->userProvider->findUserByUsername($credentials->getUsername())) {
throw new UserNotFoundException(sprintf('User "%s" not found', $credentials->getUsername()));
}
// Check if password is valid
if ( ! $this->passwordEncoder->isPasswordValid($user->getPassword(), $credentials->getPassword(), $user->getSalt())) {
throw new BadCredentialsException(sprintf('Password for user "%s" was incorrect', $credentials->getUsername()));
}
// Put user in the auth storage
$this->storage->setIdentifier($this->storageKey, $user->getUsername());
$this->user = $user;
$this->loggedIn = true;
return $user;
} | php | {
"resource": ""
} |
q263626 | AuthenticationProvider.isLoggedIn | test | public function isLoggedIn()
{
if (null === $this->loggedIn) {
$this->user = $this->loadUser();
$this->loggedIn = $this->user instanceof UserInterface;
}
return $this->loggedIn;
} | php | {
"resource": ""
} |
q263627 | AuthenticationProvider.login | test | public function login(UserInterface $user)
{
// Check if user can be found.
// Stops trying to login a user that hasn't been added to database yet
if ( ! $this->userProvider->findUserByUsername($user->getUsername())) {
throw new UserNotFoundException(sprintf('User "%s" not found', $user->getUsername()));
}
// Put user in the auth storage
$this->storage->setIdentifier($this->storageKey, $user->getUsername());
$this->user = $user;
$this->loggedIn = true;
} | php | {
"resource": ""
} |
q263628 | AuthenticationProvider.logout | test | public function logout()
{
$this->storage->removeIdentifier($this->storageKey);
$this->user = null;
$this->loggedIn = false;
} | php | {
"resource": ""
} |
q263629 | Validator.add | test | public function add($name, $constraints)
{
if ( ! isset($this->constraints[$name])) {
$this->constraints[$name] = [];
}
if (!is_array($constraints)) {
$constraints = array($constraints);
}
foreach ($constraints as $constraint) {
$this->constraints[$name][] = $constraint;
}
return $this;
} | php | {
"resource": ""
} |
q263630 | Validator.validate | test | public function validate($input)
{
$this->messages = [];
$this->input = $input;
/**
* @var ConstraintInterface $constraint
*/
foreach ($this->constraints as $field => $constraints) {
foreach ($constraints as $constraint) {
// If value is empty and rule needs a value we can skip
// checking the field
if ($constraint->shouldSkipOnNoValue() && $this->isValueEmpty($this->getInput($field))) {
continue;
}
$constraint->validate($this, $field, $this->getInput($field));
}
}
return count($this->messages) === 0;
} | php | {
"resource": ""
} |
q263631 | RedirectController.urlRedirectAction | test | public function urlRedirectAction(Request $request, $path, $permanent = false, $scheme = null, $httpPort = null, $httpsPort = null)
{
/** @var ConfigInterface $config */
$config = $this->container->get('config');
if ('' == $path) {
throw new HttpException($permanent ? 410 : 404);
}
$statusCode = $permanent ? 301 : 302;
// redirect if the path is a full URL
if (parse_url($path, PHP_URL_SCHEME)) {
return new RedirectResponse($path, $statusCode);
}
if (null === $scheme) {
$scheme = $request->getScheme();
}
$qs = $request->getQueryString();
if ($qs) {
if (strpos($path, '?') === false) {
$qs = '?'.$qs;
}
else {
$qs = '&'.$qs;
}
}
$port = '';
if ('http' === $scheme) {
if (null === $httpPort) {
if ('http' === $request->getScheme()) {
$httpPort = $request->getPort();
}
elseif ($config->has('request.http_port')) {
$httpPort = $config->get('request.http_port');
}
}
if (null !== $httpPort && 80 != $httpPort) {
$port = ":$httpPort";
}
}
elseif ('https' === $scheme) {
if (null === $httpsPort) {
if ('https' === $request->getScheme()) {
$httpsPort = $request->getPort();
}
elseif ($config->has('request.https_port')) {
$httpsPort = $config->get('request.https_port');
}
}
if (null !== $httpsPort && 443 != $httpsPort) {
$port = ":$httpsPort";
}
}
$url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs;
return new RedirectResponse($url, $statusCode);
} | php | {
"resource": ""
} |
q263632 | Bundle.getPath | test | public function getPath()
{
if (null === $this->path) {
$reflected = new \ReflectionObject($this);
$this->path = dirname($reflected->getFileName());
}
return $this->path;
} | php | {
"resource": ""
} |
q263633 | Messages.get | test | public function get(int $index): string
{
if (! array_key_exists($index, $this->messages)) {
throw new \OutOfBoundsException('Message does not exists');
}
return $this->messages[$index];
} | php | {
"resource": ""
} |
q263634 | CustomPostType.generateCustomPostTypeName | test | protected function generateCustomPostTypeName()
{
$matches = [];
preg_match('@(\\\\)?([\w]+)$@', get_called_class(), $matches);
$cptName = strtolower(
preg_replace('/(?<=\\w)(?=[A-Z])/', "-$1", $matches[2])
);
return $cptName;
} | php | {
"resource": ""
} |
q263635 | UrlExtension.getFunctions | test | public function getFunctions()
{
return array(
new \Twig_SimpleFunction('base_url', array($this, 'getBaseUrl')),
new \Twig_SimpleFunction('current_url', array($this, 'getCurrentUrl')),
new \Twig_SimpleFunction('asset_url', array($this, 'asset')),
new \Twig_SimpleFunction('url_to', array($this, 'to')),
new \Twig_SimpleFunction('secure_url_to', array($this, 'secureTo')),
new \Twig_SimpleFunction('route', array($this, 'route')),
);
} | php | {
"resource": ""
} |
q263636 | CommandHandlerResolver.resolve | test | public function resolve(CommandInterface $command)
{
$handlerClass = $this->getHandlerClass($command);
try {
$handler = $this->container->get($handlerClass);
return $handler;
}
catch(\Exception $e) {
return null;
}
} | php | {
"resource": ""
} |
q263637 | AbstractValidator.setup | test | protected function setup(CFDIReader $cfdi, Issues $issues)
{
$this->errors = $issues->messages(IssuesTypes::ERROR);
$this->warnings = $issues->messages(IssuesTypes::WARNING);
$this->comprobante = $cfdi->comprobante();
} | php | {
"resource": ""
} |
q263638 | AbstractValidator.sumNodes | test | protected function sumNodes(SimpleXMLElement $collection = null, $attribute = '')
{
if (null === $collection) {
return 0;
}
$sum = 0;
if ('' === $attribute) {
foreach ($collection as $node) {
$sum = $sum + $this->value($node);
}
} else {
foreach ($collection as $node) {
$sum = $sum + $this->value($node[$attribute]);
}
}
return $sum;
} | php | {
"resource": ""
} |
q263639 | OldInputBag.get | test | public function get($name, $default = null)
{
if ( ! $this->has($name)) {
return $default;
}
$return = $this->oldInput[$name];
unset($this->oldInput[$name]);
return $return;
} | php | {
"resource": ""
} |
q263640 | CustomTaxonomy.setSequentialPosition | test | public function setSequentialPosition($position, MetaDataBinding $context)
{
add_action('do_meta_boxes', function ($post_type) use ($position, $context) {
global $wp_meta_boxes;
if ($context->getBindingName() !== $post_type) {
return;
}
foreach ($wp_meta_boxes[$post_type]['side']['core'] as $key => $metaBox) {
// Don't replace our recently positioned taxonomy
if (preg_match('/^understory-taxonomy.+/', $key)) {
continue;
}
if (
is_array($metaBox)
&& isset($metaBox['args'])
&& is_array($metaBox['args'])
&& isset($metaBox['args']['taxonomy'])
&& $metaBox['args']['taxonomy'] === $this->getBindingName()
) {
$wp_meta_boxes[$post_type]['side']['core']['understory-taxonomy' . $position] = $metaBox;
unset($wp_meta_boxes[$post_type]['side']['core'][$key]);
}
}
}, 10000, 1);
} | php | {
"resource": ""
} |
q263641 | CustomTaxonomy.generateTaxonomyName | test | protected function generateTaxonomyName()
{
$matches = [];
preg_match('@\\\\([\w]+)$@', get_called_class(), $matches);
$taxonomyName = strtolower(
preg_replace('/(?<=\\w)(?=[A-Z])/', "-$1", $matches[1])
);
// Use the existing WordPress taxonomy post_tag with an underscore
if ($taxonomyName === 'post-tag') {
$taxonomyName = 'post_tag';
}
return $taxonomyName;
} | php | {
"resource": ""
} |
q263642 | RedirectableUrlMatcher.redirect | test | public function redirect($path, $route, $scheme = null)
{
return [
'_controller' => 'Tomahawk\\Routing\\Controller\\RedirectController::urlRedirectAction',
'path' => $path,
'permanent' => true,
'scheme' => $scheme,
'httpPort' => $this->context->getHttpPort(),
'httpsPort' => $this->context->getHttpsPort(),
'_route' => $route,
];
} | php | {
"resource": ""
} |
q263643 | Application.registerCommands | test | protected function registerCommands()
{
if ($this->commandsRegistered) {
return;
}
$this->commandsRegistered = true;
$this->kernel->boot();
foreach ($this->kernel->getBundles() as $bundle) {
if ($bundle instanceof Bundle) {
$bundle->registerCommands($this);
}
}
} | php | {
"resource": ""
} |
q263644 | DisconnectedMetadataFactory.getBundleMetadata | test | public function getBundleMetadata(BundleInterface $bundle)
{
$namespace = $bundle->getNamespace();
$metadata = $this->getMetadataForNamespace($namespace);
if (!$metadata->getMetadata()) {
throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundle->getName()));
}
$path = $this->getBasePathForClass($bundle->getName(), $bundle->getNamespace(), $bundle->getPath());
$metadata->setPath($path);
$metadata->setNamespace($bundle->getNamespace());
return $metadata;
} | php | {
"resource": ""
} |
q263645 | DisconnectedMetadataFactory.getNamespaceMetadata | test | public function getNamespaceMetadata($namespace, $path = null)
{
$metadata = $this->getMetadataForNamespace($namespace);
if (!$metadata->getMetadata()) {
throw new \RuntimeException(sprintf('Namespace "%s" does not contain any mapped entities.', $namespace));
}
$this->findNamespaceAndPathForMetadata($metadata, $path);
return $metadata;
} | php | {
"resource": ""
} |
q263646 | DisconnectedMetadataFactory.findNamespaceAndPathForMetadata | test | public function findNamespaceAndPathForMetadata(ClassMetadataCollection $metadata, $path = null)
{
$all = $metadata->getMetadata();
if (class_exists($all[0]->name)) {
$r = new \ReflectionClass($all[0]->name);
$path = $this->getBasePathForClass($r->getName(), $r->getNamespaceName(), dirname($r->getFilename()));
$ns = $r->getNamespaceName();
} elseif ($path) {
// Get namespace by removing the last component of the FQCN
$nsParts = explode('\\', $all[0]->name);
array_pop($nsParts);
$ns = implode('\\', $nsParts);
} else {
throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $all[0]->name));
}
$metadata->setPath($path);
$metadata->setNamespace($ns);
} | php | {
"resource": ""
} |
q263647 | AssetContainer.add | test | protected function add($type, $name, $source, $dependencies, $attributes)
{
$dependencies = (array) $dependencies;
$attributes = (array) $attributes;
$this->assets[$type][$name] = compact('source', 'dependencies', 'attributes');
return $this;
} | php | {
"resource": ""
} |
q263648 | Controller.render | test | public function render($view, array $parameters = [], Response $response = null)
{
$content = $this->renderView($view, $parameters);
if (null === $response) {
$response = new Response();
}
$response->setContent($content);
return $response;
} | php | {
"resource": ""
} |
q263649 | CacheManager.save | test | public function save($id, $value, $lifetime = false)
{
$this->cacheProvider->save($id, $value, $lifetime);
} | php | {
"resource": ""
} |
q263650 | CFDICleaner.loadContent | test | public function loadContent(string $content)
{
// run this method with libxml internal errors enabled
if (true !== libxml_use_internal_errors(true)) {
try {
$this->loadContent($content);
} finally {
libxml_use_internal_errors(false);
}
}
libxml_clear_errors(); // clear previous libxml errors
$dom = new DOMDocument();
@$dom->loadXML($content, LIBXML_NOWARNING | LIBXML_NONET);
if (false !== $loaderror = libxml_get_last_error()) {
libxml_clear_errors(); // clear recently libxml errors
throw new CFDICleanerException('XML Error: ' . $loaderror->message);
}
$prefix = $dom->lookupPrefix('http://www.sat.gob.mx/cfd/3');
if (! $prefix) {
throw new CFDICleanerException('The XML document is not a CFDI');
}
$version = $this->xpathQuery('/' . $prefix . ':Comprobante/@version', $dom->documentElement);
if ($version->length != 1) {
$version = $this->xpathQuery('/' . $prefix . ':Comprobante/@Version', $dom->documentElement);
}
if ($version->length != 1) {
throw new CFDICleanerException('The XML document does not contains a version');
}
if (! $this->isVersionAllowed($version->item(0)->nodeValue)) {
throw new CFDICleanerException(
'The XML document version "' . $version->item(0)->nodeValue . '" is not compatible'
);
}
$this->dom = $dom;
} | php | {
"resource": ""
} |
q263651 | CFDICleaner.removeNonSatNSschemaLocations | test | public function removeNonSatNSschemaLocations()
{
$xsi = $this->dom->lookupPrefix('http://www.w3.org/2001/XMLSchema-instance');
if (! $xsi) {
return;
}
$schemaLocations = $this->xpathQuery("//@$xsi:schemaLocation");
if ($schemaLocations->length === 0) {
return;
}
for ($s = 0; $s < $schemaLocations->length; $s++) {
$this->removeNonSatNSschemaLocation($schemaLocations->item($s));
}
} | php | {
"resource": ""
} |
q263652 | CFDICleaner.removeNonSatNSNodes | test | public function removeNonSatNSNodes()
{
$nss = [];
foreach ($this->xpathQuery('//namespace::*') as $node) {
$namespace = $node->nodeValue;
if ($this->isNameSpaceAllowed($namespace)) {
continue;
}
$nss[] = $namespace;
}
if (! count($nss)) {
return;
}
foreach ($nss as $namespace) {
$this->removeNonSatNSNode($namespace);
}
} | php | {
"resource": ""
} |
q263653 | CFDICleaner.removeUnusedNamespaces | test | public function removeUnusedNamespaces()
{
$nss = [];
foreach ($this->xpathQuery('//namespace::*') as $node) {
$namespace = $node->nodeValue;
if (! $namespace || $this->isNameSpaceAllowed($namespace)) {
continue;
}
$prefix = $this->dom->lookupPrefix($namespace);
$nss[$prefix] = $namespace;
}
$nss = array_unique($nss);
foreach ($nss as $prefix => $namespace) {
$this->dom->documentElement->removeAttributeNS($namespace, $prefix);
}
} | php | {
"resource": ""
} |
q263654 | View.initializeBindings | test | protected function initializeBindings()
{
if (!$this->getMetaDataBinding()) {
$siteClass = get_class($this->site);
if ($binding = $siteClass::getPost()) {
$this->setMetaDataBinding($binding);
}
}
$this->bindRegistryItems();
} | php | {
"resource": ""
} |
q263655 | View.bindRegistryItems | test | protected function bindRegistryItems()
{
foreach ($this->registry as $registerable) {
if ($registerable instanceof DelegatesMetaDataBinding) {
$registerable->setMetaDataBinding($this->getMetaDataBinding());
}
}
} | php | {
"resource": ""
} |
q263656 | View.getFileNameDashedCase | test | public function getFileNameDashedCase()
{
$calledClass = preg_replace('/.*Views/i', '', get_called_class());
$calledClass = strtolower(
preg_replace('/(?<=\\w)(?=[A-Z])/', '-$1', $calledClass)
);
return str_replace('\\', DIRECTORY_SEPARATOR, $calledClass);
} | php | {
"resource": ""
} |
q263657 | View.initializeContext | test | private function initializeContext()
{
$this->context = Timber\Timber::get_context();
$this->context['page'] = $this;
$this->context['post'] = $this->getMetaDataBinding();
$this->context = $this->configureContext($this->context);
foreach ($this->contextRegistry as $key => $value) {
if (is_callable($value)) {
$value = call_user_func($value);
}
$this->context[$key] = $value;
}
return $this->context;
} | php | {
"resource": ""
} |
q263658 | View.render | test | public function render()
{
$this->initializeBindings();
return Timber\Timber::compile($this->getTemplate(), $this->initializeContext());
} | php | {
"resource": ""
} |
q263659 | ConfigManager.load | test | public function load($force = false)
{
$this->config = array();
// Check if we have a compiled cached file
if ( ! $force && $this->cacheFile && file_exists($this->cacheFile)) {
$this->config = include($this->cacheFile);
return;
}
foreach ($this->configDirectories as $configDirectory) {
$finder = new Finder();
$finder->in($configDirectory)->depth('== 0')->files()->name('*.php');
foreach ($finder as $file) {
/**
* @var \Symfony\Component\Finder\SplFileInfo $file
*/
// If file starts with config_ its a compiled one so ignore
if (Str::is($file->getFilename(), '*config_*')) {
continue;
}
$configName = substr($file->getFilename(), 0, -4);
$values = $this->loader->load($file->getRealPath());
foreach ($values as $config => $value) {
$key = sprintf('%s.%s', $configName, $config);
$this->set($key, $value);
}
}
}
} | php | {
"resource": ""
} |
q263660 | Router.match | test | public function match($path, $name, $callback = null, array $schemes = [])
{
return $this->any($path, $name, $callback, $schemes);
} | php | {
"resource": ""
} |
q263661 | Router.section | test | public function section($name, $options = [], \Closure $callback)
{
$sub_collection = new RouteCollection();
$sub_router = new self();
$sub_router->setInSection(true);
$sub_router->setRoutes($sub_collection);
$callback($sub_router, $sub_collection);
$sub_collection->addPrefix($name);
$sub_collection->addDefaults($options);
$this->getRoutes()->addCollection($sub_collection);
return $this;
} | php | {
"resource": ""
} |
q263662 | Router.group | test | public function group($options, \Closure $callback)
{
$prefix = null;
if ( ! (is_string($options) || is_array($options))) {
throw new \RuntimeException('Options must either be a string or array');
}
if (is_string($options)) {
$prefix = $options;
$options = [];
}
else if (is_array($options) && isset($options['prefix'])) {
$prefix = $options['prefix'];
}
$subCollection = new RouteCollection();
$subRouter = new self();
$subRouter
->setInGroup(true)
->setRoutes($subCollection);
$callback($subRouter, $subCollection);
if ($prefix) {
$subCollection->addPrefix($prefix);
}
if ($options) {
if (isset($options['domain'])) {
$subCollection->setHost($options['domain']);
}
if (isset($options['schemes'])) {
$subCollection->setSchemes($options['schemes']);
}
if (isset($options['methods'])) {
$subCollection->setMethods($options['methods']);
}
if (isset($options['defaults'])) {
$subCollection->addDefaults($options['defaults']);
}
if (isset($options['options'])) {
$subCollection->addOptions($options['options']);
}
if (isset($options['requirements'])) {
$subCollection->addRequirements($options['requirements']);
}
}
$this->getRoutes()->addCollection($subCollection);
return $this;
} | php | {
"resource": ""
} |
q263663 | BlocksHelper.start | test | public function start($name)
{
if (in_array($name, $this->openBlocks)) {
throw new \InvalidArgumentException(sprintf('A block named "%s" is already started.', $name));
}
$this->openBlocks[] = $name;
$this->blocks[$name] = '';
ob_start();
ob_implicit_flush(0);
} | php | {
"resource": ""
} |
q263664 | BlocksHelper.stop | test | public function stop()
{
if (!$this->openBlocks) {
throw new \LogicException('No block started.');
}
$name = array_pop($this->openBlocks);
$this->blocks[$name] = ob_get_clean();
} | php | {
"resource": ""
} |
q263665 | BlocksHelper.output | test | public function output($name, $default = false)
{
if (isset($this->blocks[$name])) {
echo $this->blocks[$name];
return true;
}
if (isset($this->blockDefaults[$name])) {
echo $this->blockDefaults[$name];
return true;
}
if (false !== $default) {
echo $default;
return true;
}
return false;
} | php | {
"resource": ""
} |
q263666 | ControllerResolver.createController | test | protected function createController($controller)
{
if (false === strpos($controller, '::')) {
$count = substr_count($controller, ':');
if (2 == $count && $this->parser) {
// controller in the a:b:c notation then
$controller = $this->parser->parse($controller);
}
else if (1 == $count) {
// controller in the service:method notation
list($service, $method) = explode(':', $controller, 2);
return array($this->container->get($service), $method);
}
else if ($this->container->has($controller) && method_exists($service = $this->container->get($controller), '__invoke')) {
return $service;
}
else {
throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
}
}
list($class, $method) = explode('::', $controller, 2);
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$controller = $this->instantiateController($class);
return array($controller, $method);
} | php | {
"resource": ""
} |
q263667 | ControllerResolver.instantiateController | test | protected function instantiateController($class)
{
$reflector = new ReflectionClass($class);
$constructor = $reflector->getConstructor();
if ($constructor && $constructor->getParameters()) {
$controller = $this->container->get($class);
}
else {
$controller = new $class();
}
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
return $controller;
} | php | {
"resource": ""
} |
q263668 | UrlGenerator.validateUrl | test | public function validateUrl($url)
{
foreach ($this->validUrlStartChars as $char) {
if (0 === strpos($url, $char)) {
return true;
}
}
return false !== filter_var($url, FILTER_VALIDATE_URL);
} | php | {
"resource": ""
} |
q263669 | FilesystemLoader.findTemplate | test | protected function findTemplate($template, $throw = true)
{
$logicalName = (string) $template;
if (isset($this->cache[$logicalName])) {
return $this->cache[$logicalName];
}
$file = null;
try {
$file = parent::findTemplate($logicalName);
} catch (\Twig_Error_Loader $e) {
$twigLoaderException = $e;
// for BC
try {
$template = $this->parser->parse($template);
$file = $this->locator->locate($template);
} catch (\Exception $e) {
}
}
if (false === $file || null === $file) {
if ($throw) {
throw $twigLoaderException;
}
return false;
}
return $this->cache[$logicalName] = $file;
} | php | {
"resource": ""
} |
q263670 | CommandHelper.setApplicationEntityManager | test | static public function setApplicationEntityManager(Application $application, $emName)
{
/** @var $em \Doctrine\ORM\EntityManager */
$em = $application->getKernel()->getContainer()->get('doctrine')->getManager($emName);
$helperSet = $application->getHelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
} | php | {
"resource": ""
} |
q263671 | CommandHelper.setApplicationConnection | test | static public function setApplicationConnection(Application $application, $connName)
{
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName);
$helperSet = $application->getHelperSet();
$helperSet->set(new ConnectionHelper($connection), 'db');
} | php | {
"resource": ""
} |
q263672 | Site.renderView | test | public function renderView($template)
{
if (array_key_exists($template, $this->views)) {
echo $this->views[$template]->render();
return false;
}
return $template;
} | php | {
"resource": ""
} |
q263673 | Form.open | test | public function open()
{
$attributes = [
'method' => $this->method,
'action' => $this->url
];
$attributes = array_merge($attributes, $this->attributes);
return sprintf('<form%s>', $this->attributes($attributes));
} | php | {
"resource": ""
} |
q263674 | Form.addTransformers | test | public function addTransformers(array $dataTransformers)
{
foreach ($dataTransformers as $type => $dataTransformer) {
if ( ! $dataTransformer instanceof DataTransformerInterface) {
throw new InvalidDataTransformerException();
}
$this->addTransformer($type, $dataTransformer);
}
return $this;
} | php | {
"resource": ""
} |
q263675 | Client.public | test | function public ($segment, array $parameters=[], $version='v1.1') {
$options = [
'http' => [
'method' => 'GET',
'timeout' => 10,
],
];
$publicUrl = $this->getPublicUrl($version);
$url = $publicUrl . $segment . '?' . http_build_query(array_filter($parameters));
$feed = file_get_contents($url, false, stream_context_create($options));
return json_decode($feed, true);
} | php | {
"resource": ""
} |
q263676 | Client.market | test | public function market($segment, array $parameters=[]) {
$baseUrl = $this->marketUrl;
return $this->nonPublicRequest($baseUrl, $segment, $parameters);
} | php | {
"resource": ""
} |
q263677 | Client.account | test | public function account($segment, array $parameters=[]) {
$baseUrl = $this->accountUrl;
return $this->nonPublicRequest($baseUrl, $segment, $parameters);
} | php | {
"resource": ""
} |
q263678 | Meta.prepareAttributes | test | public static function prepareAttributes(array $attributes)
{
return [
'title' => Arr::get($attributes, 'title'),
'description' => Arr::get($attributes, 'description'),
'keywords' => Arr::get($attributes, 'keywords', []),
'extras' => Arr::get($attributes, 'extras', []),
'noindex' => Arr::get($attributes, 'noindex', false),
];
} | php | {
"resource": ""
} |
q263679 | Meta.addExtra | test | public function addExtra($key, $value)
{
return $this->setExtras(
$this->extras->put($key, $value)->all()
);
} | php | {
"resource": ""
} |
q263680 | RecordSet.fetchObject | test | function fetchObject($className = '\\stdClass', $params = array())
{
if ($className) {
if ($params) {
return mysqli_fetch_object($this->result, $className, $params);
} else {
return mysqli_fetch_object($this->result, $className);
}
} else {
return mysqli_fetch_object($this->result);
}
} | php | {
"resource": ""
} |
q263681 | UI.dialog | test | static function dialog($openControlId, $message, array $action = array())
{
Manialink::appendScript(static::getDialog($openControlId, $message, $action));
} | php | {
"resource": ""
} |
q263682 | Connection.getInstance | test | static function getInstance()
{
if (\array_key_exists('default', static::$connections)) {
return static::$connections['default'];
}
$config = Config::getInstance();
$params = new ConnectionParams();
$params->id = 'default';
$params->host = $config->host;
$params->user = $config->user;
$params->password = $config->password;
$params->database = $config->database;
$params->charset = $config->charset;
$params->persistent = $config->persistent;
return static::factory($params);
} | php | {
"resource": ""
} |
q263683 | Connection.beginTransaction | test | function beginTransaction()
{
if ($this->transactionRollback) {
throw new Exception('Transaction must be rollback\'ed!');
}
if ($this->transactionRefCount === null) {
$this->execute('BEGIN');
$this->transactionRefCount = 1;
} else {
$this->transactionRefCount++;
}
} | php | {
"resource": ""
} |
q263684 | Maniacode.load | test | final public static function load($noconfirmation = false,
$createManialinkElement = true)
{
self::$domDocument = new \DOMDocument('1.0', 'utf8');
self::$parentNodes = array();
if ($createManialinkElement) {
$maniacode = self::$domDocument->createElement('maniacode');
if ($noconfirmation)
$maniacode->setAttribute('noconfirmation', $noconfirmation);
self::$domDocument->appendChild($maniacode);
self::$parentNodes[] = $maniacode;
}
} | php | {
"resource": ""
} |
q263685 | Maniacode.render | test | final public static function render($return = false)
{
if ($return) {
return self::$domDocument->saveXML();
} else {
header('Content-Type: text/xml; charset=utf-8');
echo self::$domDocument->saveXML();
exit();
}
} | php | {
"resource": ""
} |
q263686 | Client.connect | test | public function connect(){
$this->stream = stream_socket_client('tcp://'.$this->host.':'.$this->port, $errno, $errstr, 10);
if(!$this->stream){
throw new Exception("Error $errno : $errstr");
}
return fgets($this->stream);
} | php | {
"resource": ""
} |
q263687 | Client.watch | test | public function watch($enable = true, $format = 'json'){
if($enable){
fwrite($this->stream, '?WATCH={"enable":true,"'.$format.'":true}');
}else{
fwrite($this->stream, '?WATCH={"enable":false}');
}
} | php | {
"resource": ""
} |
q263688 | Element.setBgcolor | test | function setBgcolor($bgcolor)
{
$this->bgcolor = $bgcolor;
$this->setStyle(null);
$this->setSubStyle(null);
} | php | {
"resource": ""
} |
q263689 | Element.setImage | test | function setImage($image, $absoluteUrl = false)
{
$this->setStyle(null);
$this->setSubStyle(null);
if (!$absoluteUrl) {
$this->image = Manialink::$imagesURL . $image;
} else {
$this->image = $image;
}
} | php | {
"resource": ""
} |
q263690 | Element.setImageid | test | function setImageid($imageid)
{
$this->setStyle(null);
$this->setSubStyle(null);
$this->imageid = $imageid;
} | php | {
"resource": ""
} |
q263691 | Element.setImageFocus | test | function setImageFocus($imageFocus, $absoluteUrl = false)
{
$this->setStyle(null);
$this->setSubStyle(null);
if (!$absoluteUrl) {
$this->imageFocus = Manialink::$imagesURL . $imageFocus;
} else {
$this->imageFocus = $imageFocus;
}
} | php | {
"resource": ""
} |
q263692 | Element.setImageFocusid | test | function setImageFocusid($imageFocusid)
{
$this->setStyle(null);
$this->setSubStyle(null);
$this->imageFocusid = $imageFocusid;
} | php | {
"resource": ""
} |
q263693 | Element.addLink | test | function addLink(\ManiaLib\Gui\Element $object)
{
$this->manialink = $object->getManialink();
$this->url = $object->getUrl();
$this->maniazone = $object->getManiazone();
$this->goto = $object->getGoto();
$this->action = $object->getAction();
$this->actionKey = $object->getActionKey();
if ($object->getAddPlayerId()) {
$this->addPlayerId = 1;
}
} | php | {
"resource": ""
} |
q263694 | Seo.getConfig | test | public static function getConfig($key = null, $default = null)
{
$key = self::KEY.(is_null($key) ? '' : '.'.$key);
return config()->get($key, $default);
} | php | {
"resource": ""
} |
q263695 | Seo.setConfig | test | public static function setConfig($key, $value = null)
{
config()->set(self::KEY.'.'.$key, $value);
} | php | {
"resource": ""
} |
q263696 | Seo.getTrans | test | public static function getTrans($key = null, $replace = [], $locale = null)
{
return trans(self::KEY.'::'.$key, $replace, $locale);
} | php | {
"resource": ""
} |
q263697 | Collection.getArray | test | public function getArray($key, callable $callback = null)
{
$list = $this->get($key);
if (!is_array($list)) {
return [];
}
if (is_callable($callback)) {
return array_map($callback, $list);
}
return $list;
} | php | {
"resource": ""
} |
q263698 | Formatting.stripStyles | test | static function stripStyles($string)
{
$string = preg_replace('/(?<!\$)((?:\$\$)*)\$[^$0-9a-hlp]/iu', '$1', $string);
$string = self::stripLinks($string);
$string = self::stripColors($string);
return $string;
} | php | {
"resource": ""
} |
q263699 | Redirect.createOne | test | public static function createOne($oldUrl, $newUrl, $status = Response::HTTP_MOVED_PERMANENTLY)
{
$redirect = new self([
'old_url' => $oldUrl,
'new_url' => $newUrl,
'status' => $status,
]);
$redirect->save();
return $redirect;
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.