repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
floriansemm/SolrBundle | Doctrine/Hydration/ValueHydrator.php | ValueHydrator.removeFieldSuffix | protected function removeFieldSuffix($property)
{
if (($pos = strrpos($property, '_')) !== false) {
return substr($property, 0, $pos);
}
return $property;
} | php | protected function removeFieldSuffix($property)
{
if (($pos = strrpos($property, '_')) !== false) {
return substr($property, 0, $pos);
}
return $property;
} | [
"protected",
"function",
"removeFieldSuffix",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"(",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"property",
",",
"'_'",
")",
")",
"!==",
"false",
")",
"{",
"return",
"substr",
"(",
"$",
"property",
",",
"0",
",",
... | returns the clean fieldname without type-suffix
eg: title_s => title
@param string $property
@return string | [
"returns",
"the",
"clean",
"fieldname",
"without",
"type",
"-",
"suffix"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/ValueHydrator.php#L94-L101 |
floriansemm/SolrBundle | Doctrine/Hydration/ValueHydrator.php | ValueHydrator.removePrefixedKeyValues | public function removePrefixedKeyValues($value)
{
if (($pos = strrpos($value, '_')) !== false) {
return substr($value, ($pos + 1));
}
return $value;
} | php | public function removePrefixedKeyValues($value)
{
if (($pos = strrpos($value, '_')) !== false) {
return substr($value, ($pos + 1));
}
return $value;
} | [
"public",
"function",
"removePrefixedKeyValues",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"(",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"value",
",",
"'_'",
")",
")",
"!==",
"false",
")",
"{",
"return",
"substr",
"(",
"$",
"value",
",",
"(",
"$",
"pos"... | keyfield product_1 becomes 1
@param string $value
@return string | [
"keyfield",
"product_1",
"becomes",
"1"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/ValueHydrator.php#L110-L117 |
floriansemm/SolrBundle | Doctrine/Hydration/ValueHydrator.php | ValueHydrator.toCamelCase | private function toCamelCase($fieldname)
{
$words = str_replace('_', ' ', $fieldname);
$words = ucwords($words);
$pascalCased = str_replace(' ', '', $words);
return lcfirst($pascalCased);
} | php | private function toCamelCase($fieldname)
{
$words = str_replace('_', ' ', $fieldname);
$words = ucwords($words);
$pascalCased = str_replace(' ', '', $words);
return lcfirst($pascalCased);
} | [
"private",
"function",
"toCamelCase",
"(",
"$",
"fieldname",
")",
"{",
"$",
"words",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"fieldname",
")",
";",
"$",
"words",
"=",
"ucwords",
"(",
"$",
"words",
")",
";",
"$",
"pascalCased",
"=",
"str... | returns field name camelcased if it has underlines
eg: user_id => userId
@param string $fieldname
@return string | [
"returns",
"field",
"name",
"camelcased",
"if",
"it",
"has",
"underlines"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/ValueHydrator.php#L128-L135 |
floriansemm/SolrBundle | Doctrine/Annotation/Field.php | Field.getTypeSuffix | private function getTypeSuffix($type)
{
self::$TYP_MAPPING = array_merge(self::$TYP_COMPLEX_MAPPING, self::$TYP_SIMPLE_MAPPING);
if ($type == '') {
return '';
}
if (!isset(self::$TYP_MAPPING[$this->type])) {
return '';
}
return self::$TYP_MAPPING[$this->type];
} | php | private function getTypeSuffix($type)
{
self::$TYP_MAPPING = array_merge(self::$TYP_COMPLEX_MAPPING, self::$TYP_SIMPLE_MAPPING);
if ($type == '') {
return '';
}
if (!isset(self::$TYP_MAPPING[$this->type])) {
return '';
}
return self::$TYP_MAPPING[$this->type];
} | [
"private",
"function",
"getTypeSuffix",
"(",
"$",
"type",
")",
"{",
"self",
"::",
"$",
"TYP_MAPPING",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"TYP_COMPLEX_MAPPING",
",",
"self",
"::",
"$",
"TYP_SIMPLE_MAPPING",
")",
";",
"if",
"(",
"$",
"type",
"==",
... | @param string $type
@return string | [
"@param",
"string",
"$type"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/Field.php#L99-L112 |
floriansemm/SolrBundle | Doctrine/Annotation/Field.php | Field.getBoost | public function getBoost()
{
if (!is_numeric($this->boost)) {
throw new \InvalidArgumentException(sprintf('Invalid boost value %s', $this->boost));
}
if (($boost = floatval($this->boost)) > 0) {
return $boost;
}
return null;
} | php | public function getBoost()
{
if (!is_numeric($this->boost)) {
throw new \InvalidArgumentException(sprintf('Invalid boost value %s', $this->boost));
}
if (($boost = floatval($this->boost)) > 0) {
return $boost;
}
return null;
} | [
"public",
"function",
"getBoost",
"(",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"boost",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid boost value %s'",
",",
"$",
"this",
"->",
"boost... | @throws \InvalidArgumentException if boost is not a number
@return number | [
"@throws",
"\\",
"InvalidArgumentException",
"if",
"boost",
"is",
"not",
"a",
"number"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/Field.php#L153-L164 |
floriansemm/SolrBundle | Doctrine/Annotation/Field.php | Field.normalizeName | private function normalizeName($name)
{
$words = preg_split('/(?=[A-Z])/', $name);
$words = array_map(
function ($value) {
return strtolower($value);
},
$words
);
return implode('_', $words);
} | php | private function normalizeName($name)
{
$words = preg_split('/(?=[A-Z])/', $name);
$words = array_map(
function ($value) {
return strtolower($value);
},
$words
);
return implode('_', $words);
} | [
"private",
"function",
"normalizeName",
"(",
"$",
"name",
")",
"{",
"$",
"words",
"=",
"preg_split",
"(",
"'/(?=[A-Z])/'",
",",
"$",
"name",
")",
";",
"$",
"words",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"strtolower",
... | normalize class attributes camelcased names to underscores
(according to solr specification, document field names should
contain only lowercase characters and underscores to maintain
retro compatibility with old components).
@param $name The field name
@return string normalized field name | [
"normalize",
"class",
"attributes",
"camelcased",
"names",
"to",
"underscores",
"(",
"according",
"to",
"solr",
"specification",
"document",
"field",
"names",
"should",
"contain",
"only",
"lowercase",
"characters",
"and",
"underscores",
"to",
"maintain",
"retro",
"c... | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/Field.php#L176-L187 |
floriansemm/SolrBundle | Helper/DocumentHelper.php | DocumentHelper.getLastInsertDocumentId | public function getLastInsertDocumentId($entity)
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
/** @var Query $select */
$select = $this->solariumClient->createQuery(SolariumClient::QUERY_SELECT);
$select->setQuery(sprintf('id:%s*', $metaInformation->getDocumentKey()));
$select->setRows($this->getNumberOfDocuments($metaInformation->getDocumentName()));
$select->addFields(array('id'));
$result = $this->solariumClient->select($select);
if ($result->count() == 0) {
return 0;
}
$ids = array_map(function ($document) {
return substr($document->id, stripos($document->id, '_') + 1);
}, $result->getIterator()->getArrayCopy());
return intval(max($ids));
} | php | public function getLastInsertDocumentId($entity)
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
/** @var Query $select */
$select = $this->solariumClient->createQuery(SolariumClient::QUERY_SELECT);
$select->setQuery(sprintf('id:%s*', $metaInformation->getDocumentKey()));
$select->setRows($this->getNumberOfDocuments($metaInformation->getDocumentName()));
$select->addFields(array('id'));
$result = $this->solariumClient->select($select);
if ($result->count() == 0) {
return 0;
}
$ids = array_map(function ($document) {
return substr($document->id, stripos($document->id, '_') + 1);
}, $result->getIterator()->getArrayCopy());
return intval(max($ids));
} | [
"public",
"function",
"getLastInsertDocumentId",
"(",
"$",
"entity",
")",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"/** @var Query $select */",
"$",
"select",
"=",
"$",
... | @param mixed $entity
@return int | [
"@param",
"mixed",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Helper/DocumentHelper.php#L36-L57 |
floriansemm/SolrBundle | Helper/DocumentHelper.php | DocumentHelper.getNumberOfDocuments | private function getNumberOfDocuments($documentKey)
{
$select = $this->solariumClient->createQuery(SolariumClient::QUERY_SELECT);
$select->setQuery(sprintf('id:%s_*', $documentKey));
$result = $this->solariumClient->select($select);
return $result->getNumFound();
} | php | private function getNumberOfDocuments($documentKey)
{
$select = $this->solariumClient->createQuery(SolariumClient::QUERY_SELECT);
$select->setQuery(sprintf('id:%s_*', $documentKey));
$result = $this->solariumClient->select($select);
return $result->getNumFound();
} | [
"private",
"function",
"getNumberOfDocuments",
"(",
"$",
"documentKey",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"solariumClient",
"->",
"createQuery",
"(",
"SolariumClient",
"::",
"QUERY_SELECT",
")",
";",
"$",
"select",
"->",
"setQuery",
"(",
"sprint... | @param string $documentKey
@return int | [
"@param",
"string",
"$documentKey"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Helper/DocumentHelper.php#L64-L72 |
floriansemm/SolrBundle | Query/FindByIdentifierQuery.php | FindByIdentifierQuery.getQuery | public function getQuery()
{
$idField = $this->documentKey;
if ($idField == null) {
throw new QueryException('id should not be null');
}
$documentLimitation = $this->createFilterQuery('id')->setQuery(sprintf('id:%s', $idField));
$this->addFilterQuery($documentLimitation);
$this->setQuery('*:*');
return parent::getQuery();
} | php | public function getQuery()
{
$idField = $this->documentKey;
if ($idField == null) {
throw new QueryException('id should not be null');
}
$documentLimitation = $this->createFilterQuery('id')->setQuery(sprintf('id:%s', $idField));
$this->addFilterQuery($documentLimitation);
$this->setQuery('*:*');
return parent::getQuery();
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"idField",
"=",
"$",
"this",
"->",
"documentKey",
";",
"if",
"(",
"$",
"idField",
"==",
"null",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"'id should not be null'",
")",
";",
"}",
"$",
"documen... | @return string
@throws QueryException when id or document_name is null | [
"@return",
"string"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/FindByIdentifierQuery.php#L27-L41 |
floriansemm/SolrBundle | Doctrine/ClassnameResolver/ClassnameResolver.php | ClassnameResolver.resolveFullQualifiedClassname | public function resolveFullQualifiedClassname($entityAlias)
{
$entityNamespaceAlias = $this->getNamespaceAlias($entityAlias);
if ($this->knownNamespaceAliases->isKnownNamespaceAlias($entityNamespaceAlias) === false) {
$e = ClassnameResolverException::fromKnownNamespaces(
$entityNamespaceAlias,
$this->knownNamespaceAliases->getAllNamespaceAliases()
);
throw $e;
}
$foundNamespace = $this->knownNamespaceAliases->getFullyQualifiedNamespace($entityNamespaceAlias);
$realClassName = $this->getFullyQualifiedClassname($foundNamespace, $entityAlias);
if (class_exists($realClassName) === false) {
throw new ClassnameResolverException(sprintf('class %s does not exist', $realClassName));
}
return $realClassName;
} | php | public function resolveFullQualifiedClassname($entityAlias)
{
$entityNamespaceAlias = $this->getNamespaceAlias($entityAlias);
if ($this->knownNamespaceAliases->isKnownNamespaceAlias($entityNamespaceAlias) === false) {
$e = ClassnameResolverException::fromKnownNamespaces(
$entityNamespaceAlias,
$this->knownNamespaceAliases->getAllNamespaceAliases()
);
throw $e;
}
$foundNamespace = $this->knownNamespaceAliases->getFullyQualifiedNamespace($entityNamespaceAlias);
$realClassName = $this->getFullyQualifiedClassname($foundNamespace, $entityAlias);
if (class_exists($realClassName) === false) {
throw new ClassnameResolverException(sprintf('class %s does not exist', $realClassName));
}
return $realClassName;
} | [
"public",
"function",
"resolveFullQualifiedClassname",
"(",
"$",
"entityAlias",
")",
"{",
"$",
"entityNamespaceAlias",
"=",
"$",
"this",
"->",
"getNamespaceAlias",
"(",
"$",
"entityAlias",
")",
";",
"if",
"(",
"$",
"this",
"->",
"knownNamespaceAliases",
"->",
"i... | @param string $entityAlias
@return string
@throws ClassnameResolverException if the entityAlias could not find in any configured namespace or the class
does not exist | [
"@param",
"string",
"$entityAlias"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/ClassnameResolver/ClassnameResolver.php#L32-L53 |
floriansemm/SolrBundle | Doctrine/ClassnameResolver/ClassnameResolverException.php | ClassnameResolverException.fromKnownNamespaces | public static function fromKnownNamespaces($entityNamespaceAlias, array $knownNamespaces)
{
$flattenListOfAllAliases = implode(',', $knownNamespaces);
return new ClassnameResolverException(
sprintf('could not resolve classname for entity %s, known aliase(s) are: %s', $entityNamespaceAlias, $flattenListOfAllAliases)
);
} | php | public static function fromKnownNamespaces($entityNamespaceAlias, array $knownNamespaces)
{
$flattenListOfAllAliases = implode(',', $knownNamespaces);
return new ClassnameResolverException(
sprintf('could not resolve classname for entity %s, known aliase(s) are: %s', $entityNamespaceAlias, $flattenListOfAllAliases)
);
} | [
"public",
"static",
"function",
"fromKnownNamespaces",
"(",
"$",
"entityNamespaceAlias",
",",
"array",
"$",
"knownNamespaces",
")",
"{",
"$",
"flattenListOfAllAliases",
"=",
"implode",
"(",
"','",
",",
"$",
"knownNamespaces",
")",
";",
"return",
"new",
"ClassnameR... | @param string $entityNamespaceAlias
@param array $knownNamespaces
@return ClassnameResolverException | [
"@param",
"string",
"$entityNamespaceAlias",
"@param",
"array",
"$knownNamespaces"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/ClassnameResolver/ClassnameResolverException.php#L13-L20 |
floriansemm/SolrBundle | Query/DeleteDocumentQuery.php | DeleteDocumentQuery.getQuery | public function getQuery()
{
$idField = $this->documentKey;
if ($idField == null) {
throw new QueryException('id should not be null');
}
$this->setQuery(sprintf('id:%s', $idField));
return parent::getQuery();
} | php | public function getQuery()
{
$idField = $this->documentKey;
if ($idField == null) {
throw new QueryException('id should not be null');
}
$this->setQuery(sprintf('id:%s', $idField));
return parent::getQuery();
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"idField",
"=",
"$",
"this",
"->",
"documentKey",
";",
"if",
"(",
"$",
"idField",
"==",
"null",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"'id should not be null'",
")",
";",
"}",
"$",
"this",
... | @return string
@throws QueryException when id or document_name is null | [
"@return",
"string"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/DeleteDocumentQuery.php#L27-L38 |
floriansemm/SolrBundle | Solr.php | Solr.createQuery | public function createQuery($entity): SolrQuery
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$query = new SolrQuery();
$query->setSolr($this);
$query->setEntity($metaInformation->getClassName());
$query->setIndex($metaInformation->getIndex());
$query->setMetaInformation($metaInformation);
$query->setMappedFields($metaInformation->getFieldMapping());
return $query;
} | php | public function createQuery($entity): SolrQuery
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$query = new SolrQuery();
$query->setSolr($this);
$query->setEntity($metaInformation->getClassName());
$query->setIndex($metaInformation->getIndex());
$query->setMetaInformation($metaInformation);
$query->setMappedFields($metaInformation->getFieldMapping());
return $query;
} | [
"public",
"function",
"createQuery",
"(",
"$",
"entity",
")",
":",
"SolrQuery",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"$",
"query",
"=",
"new",
"SolrQuery",
"(",
... | @param object|string $entity entity, entity-alias or classname
@return SolrQuery | [
"@param",
"object|string",
"$entity",
"entity",
"entity",
"-",
"alias",
"or",
"classname"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L116-L128 |
floriansemm/SolrBundle | Solr.php | Solr.getQueryBuilder | public function getQueryBuilder($entity): QueryBuilderInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
return new QueryBuilder($this, $metaInformation);
} | php | public function getQueryBuilder($entity): QueryBuilderInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
return new QueryBuilder($this, $metaInformation);
} | [
"public",
"function",
"getQueryBuilder",
"(",
"$",
"entity",
")",
":",
"QueryBuilderInterface",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"return",
"new",
"QueryBuilder",
... | @param string|object $entity
@return QueryBuilderInterface | [
"@param",
"string|object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L135-L140 |
floriansemm/SolrBundle | Solr.php | Solr.getRepository | public function getRepository($entity): RepositoryInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$repositoryClass = $metaInformation->getRepository();
if (class_exists($repositoryClass)) {
$repositoryInstance = new $repositoryClass($this, $metaInformation);
if ($repositoryInstance instanceof Repository) {
return $repositoryInstance;
}
throw new SolrException(sprintf('%s must extends the FS\SolrBundle\Repository\Repository', $repositoryClass));
}
return new Repository($this, $metaInformation);
} | php | public function getRepository($entity): RepositoryInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$repositoryClass = $metaInformation->getRepository();
if (class_exists($repositoryClass)) {
$repositoryInstance = new $repositoryClass($this, $metaInformation);
if ($repositoryInstance instanceof Repository) {
return $repositoryInstance;
}
throw new SolrException(sprintf('%s must extends the FS\SolrBundle\Repository\Repository', $repositoryClass));
}
return new Repository($this, $metaInformation);
} | [
"public",
"function",
"getRepository",
"(",
"$",
"entity",
")",
":",
"RepositoryInterface",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"$",
"repositoryClass",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L145-L161 |
floriansemm/SolrBundle | Solr.php | Solr.createQueryBuilder | public function createQueryBuilder($entity): QueryBuilderInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
return new QueryBuilder($this, $metaInformation);
} | php | public function createQueryBuilder($entity): QueryBuilderInterface
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
return new QueryBuilder($this, $metaInformation);
} | [
"public",
"function",
"createQueryBuilder",
"(",
"$",
"entity",
")",
":",
"QueryBuilderInterface",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"return",
"new",
"QueryBuilder"... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L166-L171 |
floriansemm/SolrBundle | Solr.php | Solr.removeDocument | public function removeDocument($entity)
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$event = new Event($this->solrClientCore, $metaInformation);
$this->eventManager->dispatch(Events::PRE_DELETE, $event);
if ($document = $this->entityMapper->toDocument($metaInformation)) {
try {
$indexName = $metaInformation->getIndex();
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->delete($document, $indexName);
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, $metaInformation, 'delete-document', $event);
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
$this->eventManager->dispatch(Events::POST_DELETE, $event);
}
} | php | public function removeDocument($entity)
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
$event = new Event($this->solrClientCore, $metaInformation);
$this->eventManager->dispatch(Events::PRE_DELETE, $event);
if ($document = $this->entityMapper->toDocument($metaInformation)) {
try {
$indexName = $metaInformation->getIndex();
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->delete($document, $indexName);
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, $metaInformation, 'delete-document', $event);
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
$this->eventManager->dispatch(Events::POST_DELETE, $event);
}
} | [
"public",
"function",
"removeDocument",
"(",
"$",
"entity",
")",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"$",
"event",
"=",
"new",
"Event",
"(",
"$",
"this",
"->"... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L176-L202 |
floriansemm/SolrBundle | Solr.php | Solr.addDocument | public function addDocument($entity): bool
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
if (!$this->addToIndex($metaInformation, $entity)) {
return false;
}
if ($metaInformation->isNested()) {
return false;
}
$event = new Event($this->solrClientCore, $metaInformation);
$this->eventManager->dispatch(Events::PRE_INSERT, $event);
$doc = $this->toDocument($metaInformation);
$this->addDocumentToIndex($doc, $metaInformation, $event);
$this->eventManager->dispatch(Events::POST_INSERT, $event);
return true;
} | php | public function addDocument($entity): bool
{
$metaInformation = $this->metaInformationFactory->loadInformation($entity);
if (!$this->addToIndex($metaInformation, $entity)) {
return false;
}
if ($metaInformation->isNested()) {
return false;
}
$event = new Event($this->solrClientCore, $metaInformation);
$this->eventManager->dispatch(Events::PRE_INSERT, $event);
$doc = $this->toDocument($metaInformation);
$this->addDocumentToIndex($doc, $metaInformation, $event);
$this->eventManager->dispatch(Events::POST_INSERT, $event);
return true;
} | [
"public",
"function",
"addDocument",
"(",
"$",
"entity",
")",
":",
"bool",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"addToIndex"... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L207-L229 |
floriansemm/SolrBundle | Solr.php | Solr.addToIndex | private function addToIndex(MetaInformationInterface $metaInformation, $entity): bool
{
if (!$metaInformation->hasSynchronizationFilter()) {
return true;
}
$callback = $metaInformation->getSynchronizationCallback();
if (!method_exists($entity, $callback)) {
throw new SolrException(sprintf('unknown method %s in entity %s', $callback, get_class($entity)));
}
return $entity->$callback();
} | php | private function addToIndex(MetaInformationInterface $metaInformation, $entity): bool
{
if (!$metaInformation->hasSynchronizationFilter()) {
return true;
}
$callback = $metaInformation->getSynchronizationCallback();
if (!method_exists($entity, $callback)) {
throw new SolrException(sprintf('unknown method %s in entity %s', $callback, get_class($entity)));
}
return $entity->$callback();
} | [
"private",
"function",
"addToIndex",
"(",
"MetaInformationInterface",
"$",
"metaInformation",
",",
"$",
"entity",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"metaInformation",
"->",
"hasSynchronizationFilter",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
... | @param MetaInformationInterface $metaInformation
@param object $entity
@return boolean
@throws SolrException if callback method not exists | [
"@param",
"MetaInformationInterface",
"$metaInformation",
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L239-L251 |
floriansemm/SolrBundle | Solr.php | Solr.getSelectQuery | public function getSelectQuery(AbstractQuery $query): SolariumQuery
{
$selectQuery = $this->solrClientCore->createSelect($query->getOptions());
$selectQuery->setQuery($query->getQuery());
$selectQuery->setFilterQueries($query->getFilterQueries());
$selectQuery->setSorts($query->getSorts());
$selectQuery->setFields($query->getFields());
return $selectQuery;
} | php | public function getSelectQuery(AbstractQuery $query): SolariumQuery
{
$selectQuery = $this->solrClientCore->createSelect($query->getOptions());
$selectQuery->setQuery($query->getQuery());
$selectQuery->setFilterQueries($query->getFilterQueries());
$selectQuery->setSorts($query->getSorts());
$selectQuery->setFields($query->getFields());
return $selectQuery;
} | [
"public",
"function",
"getSelectQuery",
"(",
"AbstractQuery",
"$",
"query",
")",
":",
"SolariumQuery",
"{",
"$",
"selectQuery",
"=",
"$",
"this",
"->",
"solrClientCore",
"->",
"createSelect",
"(",
"$",
"query",
"->",
"getOptions",
"(",
")",
")",
";",
"$",
... | Get select query
@param AbstractQuery $query
@return SolariumQuery | [
"Get",
"select",
"query"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L260-L270 |
floriansemm/SolrBundle | Solr.php | Solr.query | public function query(AbstractQuery $query): array
{
$entity = $query->getEntity();
$runQueryInIndex = $query->getIndex();
$selectQuery = $this->getSelectQuery($query);
try {
$response = $this->solrClientCore->select($selectQuery, $runQueryInIndex);
$this->numberOfFoundDocuments = $response->getNumFound();
$entities = array();
foreach ($response as $document) {
$entities[] = $this->entityMapper->toEntity($document, $entity);
}
return $entities;
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, null, 'query solr');
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
} | php | public function query(AbstractQuery $query): array
{
$entity = $query->getEntity();
$runQueryInIndex = $query->getIndex();
$selectQuery = $this->getSelectQuery($query);
try {
$response = $this->solrClientCore->select($selectQuery, $runQueryInIndex);
$this->numberOfFoundDocuments = $response->getNumFound();
$entities = array();
foreach ($response as $document) {
$entities[] = $this->entityMapper->toEntity($document, $entity);
}
return $entities;
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, null, 'query solr');
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"query",
"(",
"AbstractQuery",
"$",
"query",
")",
":",
"array",
"{",
"$",
"entity",
"=",
"$",
"query",
"->",
"getEntity",
"(",
")",
";",
"$",
"runQueryInIndex",
"=",
"$",
"query",
"->",
"getIndex",
"(",
")",
";",
"$",
"selectQuery... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L275-L300 |
floriansemm/SolrBundle | Solr.php | Solr.clearIndex | public function clearIndex()
{
$this->eventManager->dispatch(Events::PRE_CLEAR_INDEX, new Event($this->solrClientCore));
try {
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->clearCores();
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, null, 'clear-index');
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
$this->eventManager->dispatch(Events::POST_CLEAR_INDEX, new Event($this->solrClientCore));
} | php | public function clearIndex()
{
$this->eventManager->dispatch(Events::PRE_CLEAR_INDEX, new Event($this->solrClientCore));
try {
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->clearCores();
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, null, 'clear-index');
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
$this->eventManager->dispatch(Events::POST_CLEAR_INDEX, new Event($this->solrClientCore));
} | [
"public",
"function",
"clearIndex",
"(",
")",
"{",
"$",
"this",
"->",
"eventManager",
"->",
"dispatch",
"(",
"Events",
"::",
"PRE_CLEAR_INDEX",
",",
"new",
"Event",
"(",
"$",
"this",
"->",
"solrClientCore",
")",
")",
";",
"try",
"{",
"$",
"client",
"=",
... | clears the whole index by using the query *:*
@throws SolrException if an error occurs | [
"clears",
"the",
"whole",
"index",
"by",
"using",
"the",
"query",
"*",
":",
"*"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L317-L334 |
floriansemm/SolrBundle | Solr.php | Solr.updateDocument | public function updateDocument($entity): bool
{
$metaInformations = $this->metaInformationFactory->loadInformation($entity);
if (!$this->addToIndex($metaInformations, $entity)) {
return false;
}
$event = new Event($this->solrClientCore, $metaInformations);
$this->eventManager->dispatch(Events::PRE_UPDATE, $event);
$doc = $this->toDocument($metaInformations);
$this->addDocumentToIndex($doc, $metaInformations, $event);
$this->eventManager->dispatch(Events::POST_UPDATE, $event);
return true;
} | php | public function updateDocument($entity): bool
{
$metaInformations = $this->metaInformationFactory->loadInformation($entity);
if (!$this->addToIndex($metaInformations, $entity)) {
return false;
}
$event = new Event($this->solrClientCore, $metaInformations);
$this->eventManager->dispatch(Events::PRE_UPDATE, $event);
$doc = $this->toDocument($metaInformations);
$this->addDocumentToIndex($doc, $metaInformations, $event);
$this->eventManager->dispatch(Events::POST_UPDATE, $event);
return true;
} | [
"public",
"function",
"updateDocument",
"(",
"$",
"entity",
")",
":",
"bool",
"{",
"$",
"metaInformations",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"addToIn... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L373-L391 |
floriansemm/SolrBundle | Solr.php | Solr.toDocument | private function toDocument(MetaInformationInterface $metaInformation): DocumentInterface
{
$doc = $this->entityMapper->toDocument($metaInformation);
return $doc;
} | php | private function toDocument(MetaInformationInterface $metaInformation): DocumentInterface
{
$doc = $this->entityMapper->toDocument($metaInformation);
return $doc;
} | [
"private",
"function",
"toDocument",
"(",
"MetaInformationInterface",
"$",
"metaInformation",
")",
":",
"DocumentInterface",
"{",
"$",
"doc",
"=",
"$",
"this",
"->",
"entityMapper",
"->",
"toDocument",
"(",
"$",
"metaInformation",
")",
";",
"return",
"$",
"doc",... | @param MetaInformationInterface $metaInformation
@return DocumentInterface | [
"@param",
"MetaInformationInterface",
"$metaInformation"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L398-L403 |
floriansemm/SolrBundle | Solr.php | Solr.addDocumentToIndex | private function addDocumentToIndex($doc, MetaInformationInterface $metaInformation, Event $event)
{
try {
$indexName = $metaInformation->getIndex();
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->update($doc, $indexName);
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, $metaInformation, json_encode($this->solrClientCore->getOptions()), $event);
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
} | php | private function addDocumentToIndex($doc, MetaInformationInterface $metaInformation, Event $event)
{
try {
$indexName = $metaInformation->getIndex();
$client = new SolariumMulticoreClient($this->solrClientCore);
$client->update($doc, $indexName);
} catch (\Exception $e) {
$errorEvent = new ErrorEvent(null, $metaInformation, json_encode($this->solrClientCore->getOptions()), $event);
$errorEvent->setException($e);
$this->eventManager->dispatch(Events::ERROR, $errorEvent);
throw new SolrException($e->getMessage(), $e->getCode(), $e);
}
} | [
"private",
"function",
"addDocumentToIndex",
"(",
"$",
"doc",
",",
"MetaInformationInterface",
"$",
"metaInformation",
",",
"Event",
"$",
"event",
")",
"{",
"try",
"{",
"$",
"indexName",
"=",
"$",
"metaInformation",
"->",
"getIndex",
"(",
")",
";",
"$",
"cli... | @param object $doc
@param MetaInformationInterface $metaInformation
@param Event $event
@throws SolrException if an error occurs | [
"@param",
"object",
"$doc",
"@param",
"MetaInformationInterface",
"$metaInformation",
"@param",
"Event",
"$event"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Solr.php#L412-L428 |
floriansemm/SolrBundle | Doctrine/Mapper/Factory/DocumentFactory.php | DocumentFactory.createDocument | public function createDocument(MetaInformationInterface $metaInformation)
{
$fields = $metaInformation->getFields();
if (count($fields) == 0) {
return null;
}
if (!$metaInformation->getEntityId() && !$metaInformation->generateDocumentId()) {
throw new SolrMappingException(sprintf('No entity id set for "%s"', $metaInformation->getClassName()));
}
$documentId = $metaInformation->getDocumentKey();
if ($metaInformation->generateDocumentId()) {
$documentId = $metaInformation->getDocumentName() . '_' . Uuid::uuid1()->toString();
}
$document = new Document();
$document->setKey(MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME, $documentId);
$document->setBoost($metaInformation->getBoost());
foreach ($fields as $field) {
if (!$field instanceof Field) {
continue;
}
$fieldValue = $field->getValue();
if (($fieldValue instanceof Collection || is_array($fieldValue)) && $field->nestedClass) {
$this->mapCollectionField($document, $field, $metaInformation->getEntity());
} else if (is_object($fieldValue) && $field->nestedClass) { // index sinsgle object as nested child-document
$document->addField('_childDocuments_', [$this->objectToDocument($fieldValue)], $field->getBoost());
} else if (is_object($fieldValue) && !$field->nestedClass) { // index object as "flat" string, call getter
$document->addField($field->getNameWithAlias(), $this->mapObjectField($field), $field->getBoost());
} else if ($field->getter && $fieldValue) { // call getter to transform data (json to array, etc.)
$getterValue = $this->callGetterMethod($metaInformation->getEntity(), $field->getGetterName());
$document->addField($field->getNameWithAlias(), $getterValue, $field->getBoost());
} else { // field contains simple data-type
$document->addField($field->getNameWithAlias(), $fieldValue, $field->getBoost());
}
if ($field->getFieldModifier()) {
$document->setFieldModifier($field->getNameWithAlias(), $field->getFieldModifier());
}
}
return $document;
} | php | public function createDocument(MetaInformationInterface $metaInformation)
{
$fields = $metaInformation->getFields();
if (count($fields) == 0) {
return null;
}
if (!$metaInformation->getEntityId() && !$metaInformation->generateDocumentId()) {
throw new SolrMappingException(sprintf('No entity id set for "%s"', $metaInformation->getClassName()));
}
$documentId = $metaInformation->getDocumentKey();
if ($metaInformation->generateDocumentId()) {
$documentId = $metaInformation->getDocumentName() . '_' . Uuid::uuid1()->toString();
}
$document = new Document();
$document->setKey(MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME, $documentId);
$document->setBoost($metaInformation->getBoost());
foreach ($fields as $field) {
if (!$field instanceof Field) {
continue;
}
$fieldValue = $field->getValue();
if (($fieldValue instanceof Collection || is_array($fieldValue)) && $field->nestedClass) {
$this->mapCollectionField($document, $field, $metaInformation->getEntity());
} else if (is_object($fieldValue) && $field->nestedClass) { // index sinsgle object as nested child-document
$document->addField('_childDocuments_', [$this->objectToDocument($fieldValue)], $field->getBoost());
} else if (is_object($fieldValue) && !$field->nestedClass) { // index object as "flat" string, call getter
$document->addField($field->getNameWithAlias(), $this->mapObjectField($field), $field->getBoost());
} else if ($field->getter && $fieldValue) { // call getter to transform data (json to array, etc.)
$getterValue = $this->callGetterMethod($metaInformation->getEntity(), $field->getGetterName());
$document->addField($field->getNameWithAlias(), $getterValue, $field->getBoost());
} else { // field contains simple data-type
$document->addField($field->getNameWithAlias(), $fieldValue, $field->getBoost());
}
if ($field->getFieldModifier()) {
$document->setFieldModifier($field->getNameWithAlias(), $field->getFieldModifier());
}
}
return $document;
} | [
"public",
"function",
"createDocument",
"(",
"MetaInformationInterface",
"$",
"metaInformation",
")",
"{",
"$",
"fields",
"=",
"$",
"metaInformation",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"fields",
")",
"==",
"0",
")",
"{",
"retu... | @param MetaInformationInterface $metaInformation
@return null|Document
@throws SolrMappingException if no id is set | [
"@param",
"MetaInformationInterface",
"$metaInformation"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/Factory/DocumentFactory.php#L35-L81 |
floriansemm/SolrBundle | Doctrine/Mapper/Factory/DocumentFactory.php | DocumentFactory.mapObjectField | private function mapObjectField(Field $field)
{
$value = $field->getValue();
$getter = $field->getGetterName();
if (empty($getter)) {
throw new SolrMappingException(sprintf('Please configure a getter for property "%s" in class "%s"', $field->name, get_class($value)));
}
$getterReturnValue = $this->callGetterMethod($value, $getter);
if (is_object($getterReturnValue)) {
throw new SolrMappingException(sprintf('The configured getter "%s" in "%s" must return a string or array, got object', $getter, get_class($value)));
}
return $getterReturnValue;
} | php | private function mapObjectField(Field $field)
{
$value = $field->getValue();
$getter = $field->getGetterName();
if (empty($getter)) {
throw new SolrMappingException(sprintf('Please configure a getter for property "%s" in class "%s"', $field->name, get_class($value)));
}
$getterReturnValue = $this->callGetterMethod($value, $getter);
if (is_object($getterReturnValue)) {
throw new SolrMappingException(sprintf('The configured getter "%s" in "%s" must return a string or array, got object', $getter, get_class($value)));
}
return $getterReturnValue;
} | [
"private",
"function",
"mapObjectField",
"(",
"Field",
"$",
"field",
")",
"{",
"$",
"value",
"=",
"$",
"field",
"->",
"getValue",
"(",
")",
";",
"$",
"getter",
"=",
"$",
"field",
"->",
"getGetterName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"... | @param Field $field
@return array|string
@throws SolrMappingException if getter return value is object | [
"@param",
"Field",
"$field"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/Factory/DocumentFactory.php#L90-L105 |
floriansemm/SolrBundle | Doctrine/Mapper/Factory/DocumentFactory.php | DocumentFactory.callGetterMethod | private function callGetterMethod($object, $getter)
{
$methodName = $getter;
if (strpos($getter, '(') !== false) {
$methodName = substr($getter, 0, strpos($getter, '('));
}
if (!method_exists($object, $methodName)) {
throw new SolrMappingException(sprintf('No method "%s()" found in class "%s"', $methodName, get_class($object)));
}
$method = new \ReflectionMethod($object, $methodName);
// getter with arguments
if (strpos($getter, ')') !== false) {
$getterArguments = explode(',', substr($getter, strpos($getter, '(') + 1, -1));
$getterArguments = array_map(function ($parameter) {
return trim(preg_replace('#[\'"]#', '', $parameter));
}, $getterArguments);
return $method->invokeArgs($object, $getterArguments);
}
return $method->invoke($object);
} | php | private function callGetterMethod($object, $getter)
{
$methodName = $getter;
if (strpos($getter, '(') !== false) {
$methodName = substr($getter, 0, strpos($getter, '('));
}
if (!method_exists($object, $methodName)) {
throw new SolrMappingException(sprintf('No method "%s()" found in class "%s"', $methodName, get_class($object)));
}
$method = new \ReflectionMethod($object, $methodName);
// getter with arguments
if (strpos($getter, ')') !== false) {
$getterArguments = explode(',', substr($getter, strpos($getter, '(') + 1, -1));
$getterArguments = array_map(function ($parameter) {
return trim(preg_replace('#[\'"]#', '', $parameter));
}, $getterArguments);
return $method->invokeArgs($object, $getterArguments);
}
return $method->invoke($object);
} | [
"private",
"function",
"callGetterMethod",
"(",
"$",
"object",
",",
"$",
"getter",
")",
"{",
"$",
"methodName",
"=",
"$",
"getter",
";",
"if",
"(",
"strpos",
"(",
"$",
"getter",
",",
"'('",
")",
"!==",
"false",
")",
"{",
"$",
"methodName",
"=",
"subs... | @param object $object
@param string $getter
@return mixed
@throws SolrMappingException if given getter does not exists | [
"@param",
"object",
"$object",
"@param",
"string",
"$getter"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/Factory/DocumentFactory.php#L115-L138 |
floriansemm/SolrBundle | Doctrine/Mapper/Factory/DocumentFactory.php | DocumentFactory.mapCollectionField | private function mapCollectionField($document, Field $field, $sourceTargetObject)
{
/** @var Collection $collection */
$collection = $field->getValue();
$getter = $field->getGetterName();
if ($getter != '') {
$collection = $this->callGetterMethod($sourceTargetObject, $getter);
$collection = array_filter($collection, function ($value) {
return $value !== null;
});
}
$values = [];
if (count($collection)) {
foreach ($collection as $relatedObj) {
if (is_object($relatedObj)) {
$values[] = $this->objectToDocument($relatedObj);
} else {
$values[] = $relatedObj;
}
}
$document->addField('_childDocuments_', $values, $field->getBoost());
}
return $values;
} | php | private function mapCollectionField($document, Field $field, $sourceTargetObject)
{
/** @var Collection $collection */
$collection = $field->getValue();
$getter = $field->getGetterName();
if ($getter != '') {
$collection = $this->callGetterMethod($sourceTargetObject, $getter);
$collection = array_filter($collection, function ($value) {
return $value !== null;
});
}
$values = [];
if (count($collection)) {
foreach ($collection as $relatedObj) {
if (is_object($relatedObj)) {
$values[] = $this->objectToDocument($relatedObj);
} else {
$values[] = $relatedObj;
}
}
$document->addField('_childDocuments_', $values, $field->getBoost());
}
return $values;
} | [
"private",
"function",
"mapCollectionField",
"(",
"$",
"document",
",",
"Field",
"$",
"field",
",",
"$",
"sourceTargetObject",
")",
"{",
"/** @var Collection $collection */",
"$",
"collection",
"=",
"$",
"field",
"->",
"getValue",
"(",
")",
";",
"$",
"getter",
... | @param Field $field
@param string $sourceTargetClass
@return array
@throws SolrMappingException if no getter method was found | [
"@param",
"Field",
"$field",
"@param",
"string",
"$sourceTargetClass"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/Factory/DocumentFactory.php#L148-L176 |
floriansemm/SolrBundle | Doctrine/Mapper/Factory/DocumentFactory.php | DocumentFactory.objectToDocument | private function objectToDocument($value)
{
$metaInformation = $this->metaInformationFactory->loadInformation($value);
$field = [];
$document = $this->createDocument($metaInformation);
foreach ($document as $fieldName => $value) {
$field[$fieldName] = $value;
}
return $field;
} | php | private function objectToDocument($value)
{
$metaInformation = $this->metaInformationFactory->loadInformation($value);
$field = [];
$document = $this->createDocument($metaInformation);
foreach ($document as $fieldName => $value) {
$field[$fieldName] = $value;
}
return $field;
} | [
"private",
"function",
"objectToDocument",
"(",
"$",
"value",
")",
"{",
"$",
"metaInformation",
"=",
"$",
"this",
"->",
"metaInformationFactory",
"->",
"loadInformation",
"(",
"$",
"value",
")",
";",
"$",
"field",
"=",
"[",
"]",
";",
"$",
"document",
"=",
... | @param mixed $value
@return array
@throws SolrMappingException | [
"@param",
"mixed",
"$value"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/Factory/DocumentFactory.php#L185-L196 |
floriansemm/SolrBundle | Command/ShowSchemaCommand.php | ShowSchemaCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
$metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');
foreach ($namespaces->getEntityClassnames() as $classname) {
try {
$metaInformation = $metaInformationFactory->loadInformation($classname);
if ($metaInformation->isNested()) {
continue;
}
} catch (SolrMappingException $e) {
continue;
}
$nested = '';
if ($metaInformation->isNested()) {
$nested = '(nested)';
}
$output->writeln(sprintf('<comment>%s</comment> %s', $classname, $nested));
$output->writeln(sprintf('Documentname: %s', $metaInformation->getDocumentName()));
$output->writeln(sprintf('Document Boost: %s', $metaInformation->getBoost()?$metaInformation->getBoost(): '-'));
$simpleFields = $this->getSimpleFields($metaInformation);
$rows = [];
foreach ($simpleFields as $documentField => $property) {
if ($field = $metaInformation->getField($documentField)) {
$rows[] = [$property, $documentField, $field->boost];
}
}
$this->renderTable($output, $rows);
$nestedFields = $this->getNestedFields($metaInformation);
if (count($nestedFields) == 0) {
return;
}
$output->writeln(sprintf('Fields <comment>(%s)</comment> with nested documents', count($nestedFields)));
foreach ($nestedFields as $idField) {
$propertyName = substr($idField, 0, strpos($idField, '.'));
if ($nestedField = $metaInformation->getField($propertyName)) {
$output->writeln(sprintf('Field <comment>%s</comment> contains nested class <comment>%s</comment>', $propertyName, $nestedField->nestedClass));
$nestedDocument = $metaInformationFactory->loadInformation($nestedField->nestedClass);
$rows = [];
foreach ($nestedDocument->getFieldMapping() as $documentField => $property) {
$field = $nestedDocument->getField($documentField);
if ($field === null) {
continue;
}
$rows[] = [$property, $documentField, $field->boost];
}
$this->renderTable($output, $rows);
}
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
$metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');
foreach ($namespaces->getEntityClassnames() as $classname) {
try {
$metaInformation = $metaInformationFactory->loadInformation($classname);
if ($metaInformation->isNested()) {
continue;
}
} catch (SolrMappingException $e) {
continue;
}
$nested = '';
if ($metaInformation->isNested()) {
$nested = '(nested)';
}
$output->writeln(sprintf('<comment>%s</comment> %s', $classname, $nested));
$output->writeln(sprintf('Documentname: %s', $metaInformation->getDocumentName()));
$output->writeln(sprintf('Document Boost: %s', $metaInformation->getBoost()?$metaInformation->getBoost(): '-'));
$simpleFields = $this->getSimpleFields($metaInformation);
$rows = [];
foreach ($simpleFields as $documentField => $property) {
if ($field = $metaInformation->getField($documentField)) {
$rows[] = [$property, $documentField, $field->boost];
}
}
$this->renderTable($output, $rows);
$nestedFields = $this->getNestedFields($metaInformation);
if (count($nestedFields) == 0) {
return;
}
$output->writeln(sprintf('Fields <comment>(%s)</comment> with nested documents', count($nestedFields)));
foreach ($nestedFields as $idField) {
$propertyName = substr($idField, 0, strpos($idField, '.'));
if ($nestedField = $metaInformation->getField($propertyName)) {
$output->writeln(sprintf('Field <comment>%s</comment> contains nested class <comment>%s</comment>', $propertyName, $nestedField->nestedClass));
$nestedDocument = $metaInformationFactory->loadInformation($nestedField->nestedClass);
$rows = [];
foreach ($nestedDocument->getFieldMapping() as $documentField => $property) {
$field = $nestedDocument->getField($documentField);
if ($field === null) {
continue;
}
$rows[] = [$property, $documentField, $field->boost];
}
$this->renderTable($output, $rows);
}
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'solr.doctrine.classnameresolver.known_entity_namespaces... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/ShowSchemaCommand.php#L26-L91 |
floriansemm/SolrBundle | Command/ShowSchemaCommand.php | ShowSchemaCommand.getSimpleFields | private function getSimpleFields(MetaInformationInterface $metaInformation)
{
$simpleFields = array_filter($metaInformation->getFieldMapping(), function ($field) {
if (strpos($field, '.') === false) {
return true;
}
return false;
});
return $simpleFields;
} | php | private function getSimpleFields(MetaInformationInterface $metaInformation)
{
$simpleFields = array_filter($metaInformation->getFieldMapping(), function ($field) {
if (strpos($field, '.') === false) {
return true;
}
return false;
});
return $simpleFields;
} | [
"private",
"function",
"getSimpleFields",
"(",
"MetaInformationInterface",
"$",
"metaInformation",
")",
"{",
"$",
"simpleFields",
"=",
"array_filter",
"(",
"$",
"metaInformation",
"->",
"getFieldMapping",
"(",
")",
",",
"function",
"(",
"$",
"field",
")",
"{",
"... | @param MetaInformationInterface $metaInformation
@return array | [
"@param",
"MetaInformationInterface",
"$metaInformation"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/ShowSchemaCommand.php#L111-L122 |
floriansemm/SolrBundle | Command/ShowSchemaCommand.php | ShowSchemaCommand.getNestedFields | protected function getNestedFields(MetaInformationInterface $metaInformation)
{
$complexFields = array_filter($metaInformation->getFieldMapping(), function ($field) {
if (strpos($field, '.id') !== false) {
return true;
}
return false;
});
return $complexFields;
} | php | protected function getNestedFields(MetaInformationInterface $metaInformation)
{
$complexFields = array_filter($metaInformation->getFieldMapping(), function ($field) {
if (strpos($field, '.id') !== false) {
return true;
}
return false;
});
return $complexFields;
} | [
"protected",
"function",
"getNestedFields",
"(",
"MetaInformationInterface",
"$",
"metaInformation",
")",
"{",
"$",
"complexFields",
"=",
"array_filter",
"(",
"$",
"metaInformation",
"->",
"getFieldMapping",
"(",
")",
",",
"function",
"(",
"$",
"field",
")",
"{",
... | @param MetaInformationInterface $metaInformation
@return array | [
"@param",
"MetaInformationInterface",
"$metaInformation"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/ShowSchemaCommand.php#L129-L140 |
floriansemm/SolrBundle | Command/SynchronizeIndexCommand.php | SynchronizeIndexCommand.configure | protected function configure()
{
$this->setName('solr:index:populate')
->addArgument('entity', InputArgument::OPTIONAL, 'The entity you want to index', null)
->addOption('flushsize', null, InputOption::VALUE_OPTIONAL, 'Number of items to handle before flushing data', 500)
->addOption('source', null, InputArgument::OPTIONAL, 'specify a source from where to load entities [relational, mongodb]', null)
->addOption('start-offset', null, InputOption::VALUE_OPTIONAL, 'Start with row', 0)
->setDescription('Index all entities');
} | php | protected function configure()
{
$this->setName('solr:index:populate')
->addArgument('entity', InputArgument::OPTIONAL, 'The entity you want to index', null)
->addOption('flushsize', null, InputOption::VALUE_OPTIONAL, 'Number of items to handle before flushing data', 500)
->addOption('source', null, InputArgument::OPTIONAL, 'specify a source from where to load entities [relational, mongodb]', null)
->addOption('start-offset', null, InputOption::VALUE_OPTIONAL, 'Start with row', 0)
->setDescription('Index all entities');
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"'solr:index:populate'",
")",
"->",
"addArgument",
"(",
"'entity'",
",",
"InputArgument",
"::",
"OPTIONAL",
",",
"'The entity you want to index'",
",",
"null",
")",
"->",
"ad... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/SynchronizeIndexCommand.php#L24-L32 |
floriansemm/SolrBundle | Command/SynchronizeIndexCommand.php | SynchronizeIndexCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$entities = $this->getIndexableEntities($input->getArgument('entity'));
$source = $input->getOption('source');
if ($source !== null) {
$output->writeln('<comment>The source option is deprecated and will be removed in version 2.0</comment>');
}
$startOffset = $input->getOption('start-offset');
$batchSize = $input->getOption('flushsize');
$solr = $this->getContainer()->get('solr.client');
if ($startOffset > 0 && count($entities) > 1) {
$output->writeln('<error>Wrong usage. Please use start-offset option together with the entity argument.</error>');
return;
}
foreach ($entities as $entityClassname) {
$objectManager = $this->getObjectManager($entityClassname);
$output->writeln(sprintf('Indexing: <info>%s</info>', $entityClassname));
try {
$repository = $objectManager->getRepository($entityClassname);
} catch (\Exception $e) {
$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entityClassname));
continue;
}
$totalSize = $this->getTotalNumberOfEntities($entityClassname, $startOffset);
if ($totalSize >= 500000) {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Indexing more than 500000 entities does not perform well and can exhaust the whole memory. Execute anyway?', false);
if (!$helper->ask($input, $output, $question)) {
$output->writeln('');
continue;
}
}
if ($totalSize === 0) {
$output->writeln('<comment>No entities found for indexing</comment>');
continue;
}
$output->writeln(sprintf('Synchronize <info>%s</info> entities', $totalSize));
$batchLoops = ceil($totalSize / $batchSize);
for ($i = 0; $i <= $batchLoops; $i++) {
$offset = $i * $batchSize;
if ($startOffset && $i == 0) {
$offset = $startOffset;
$i++;
}
$entities = $repository->findBy([], null, $batchSize, $offset);
try {
$solr->synchronizeIndex($entities);
} catch (\Exception $e) {
$output->writeln(sprintf('A error occurs: %s', $e->getMessage()));
}
}
$output->writeln('<info>Synchronization finished</info>');
$output->writeln('');
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$entities = $this->getIndexableEntities($input->getArgument('entity'));
$source = $input->getOption('source');
if ($source !== null) {
$output->writeln('<comment>The source option is deprecated and will be removed in version 2.0</comment>');
}
$startOffset = $input->getOption('start-offset');
$batchSize = $input->getOption('flushsize');
$solr = $this->getContainer()->get('solr.client');
if ($startOffset > 0 && count($entities) > 1) {
$output->writeln('<error>Wrong usage. Please use start-offset option together with the entity argument.</error>');
return;
}
foreach ($entities as $entityClassname) {
$objectManager = $this->getObjectManager($entityClassname);
$output->writeln(sprintf('Indexing: <info>%s</info>', $entityClassname));
try {
$repository = $objectManager->getRepository($entityClassname);
} catch (\Exception $e) {
$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entityClassname));
continue;
}
$totalSize = $this->getTotalNumberOfEntities($entityClassname, $startOffset);
if ($totalSize >= 500000) {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Indexing more than 500000 entities does not perform well and can exhaust the whole memory. Execute anyway?', false);
if (!$helper->ask($input, $output, $question)) {
$output->writeln('');
continue;
}
}
if ($totalSize === 0) {
$output->writeln('<comment>No entities found for indexing</comment>');
continue;
}
$output->writeln(sprintf('Synchronize <info>%s</info> entities', $totalSize));
$batchLoops = ceil($totalSize / $batchSize);
for ($i = 0; $i <= $batchLoops; $i++) {
$offset = $i * $batchSize;
if ($startOffset && $i == 0) {
$offset = $startOffset;
$i++;
}
$entities = $repository->findBy([], null, $batchSize, $offset);
try {
$solr->synchronizeIndex($entities);
} catch (\Exception $e) {
$output->writeln(sprintf('A error occurs: %s', $e->getMessage()));
}
}
$output->writeln('<info>Synchronization finished</info>');
$output->writeln('');
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"getIndexableEntities",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'entity'",
")",
")",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/SynchronizeIndexCommand.php#L37-L110 |
floriansemm/SolrBundle | Command/SynchronizeIndexCommand.php | SynchronizeIndexCommand.getObjectManager | private function getObjectManager($entityClassname)
{
$objectManager = $this->getContainer()->get('doctrine')->getManagerForClass($entityClassname);
if ($objectManager) {
return $objectManager;
}
$objectManager = $this->getContainer()->get('doctrine_mongodb')->getManagerForClass($entityClassname);
if ($objectManager) {
return $objectManager;
}
throw new \RuntimeException(sprintf('Class "%s" is not a managed entity', $entityClassname));
} | php | private function getObjectManager($entityClassname)
{
$objectManager = $this->getContainer()->get('doctrine')->getManagerForClass($entityClassname);
if ($objectManager) {
return $objectManager;
}
$objectManager = $this->getContainer()->get('doctrine_mongodb')->getManagerForClass($entityClassname);
if ($objectManager) {
return $objectManager;
}
throw new \RuntimeException(sprintf('Class "%s" is not a managed entity', $entityClassname));
} | [
"private",
"function",
"getObjectManager",
"(",
"$",
"entityClassname",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManagerForClass",
"(",
"$",
"entityClassname",
")",
";",
... | @param string $entityClassname
@throws \RuntimeException if no doctrine instance is configured
@return ObjectManager | [
"@param",
"string",
"$entityClassname"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/SynchronizeIndexCommand.php#L119-L132 |
floriansemm/SolrBundle | Command/SynchronizeIndexCommand.php | SynchronizeIndexCommand.getIndexableEntities | private function getIndexableEntities($entity = null)
{
if ($entity) {
return [$entity];
}
$entities = [];
$namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
$metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');
foreach ($namespaces->getEntityClassnames() as $classname) {
try {
$metaInformation = $metaInformationFactory->loadInformation($classname);
if ($metaInformation->isNested()) {
continue;
}
array_push($entities, $metaInformation->getClassName());
} catch (SolrMappingException $e) {
continue;
}
}
return $entities;
} | php | private function getIndexableEntities($entity = null)
{
if ($entity) {
return [$entity];
}
$entities = [];
$namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
$metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');
foreach ($namespaces->getEntityClassnames() as $classname) {
try {
$metaInformation = $metaInformationFactory->loadInformation($classname);
if ($metaInformation->isNested()) {
continue;
}
array_push($entities, $metaInformation->getClassName());
} catch (SolrMappingException $e) {
continue;
}
}
return $entities;
} | [
"private",
"function",
"getIndexableEntities",
"(",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entity",
")",
"{",
"return",
"[",
"$",
"entity",
"]",
";",
"}",
"$",
"entities",
"=",
"[",
"]",
";",
"$",
"namespaces",
"=",
"$",
"this",
"->... | Get a list of entities which are indexable by Solr
@param null|string $entity
@return array | [
"Get",
"a",
"list",
"of",
"entities",
"which",
"are",
"indexable",
"by",
"Solr"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/SynchronizeIndexCommand.php#L141-L165 |
floriansemm/SolrBundle | Command/SynchronizeIndexCommand.php | SynchronizeIndexCommand.getTotalNumberOfEntities | private function getTotalNumberOfEntities($entity, $startOffset)
{
$objectManager = $this->getObjectManager($entity);
$repository = $objectManager->getRepository($entity);
if ($repository instanceof DocumentRepository) {
$totalSize = $repository->createQueryBuilder()
->getQuery()
->count();
} else {
$dataStoreMetadata = $objectManager->getClassMetadata($entity);
$identifierFieldNames = $dataStoreMetadata->getIdentifierFieldNames();
if (!count($identifierFieldNames)) {
throw new \Exception(sprintf('No primary key found for entity %s', $entity));
}
$countableColumn = reset($identifierFieldNames);
/** @var EntityRepository $repository */
$totalSize = $repository->createQueryBuilder('size')
->select(sprintf('count(size.%s)', $countableColumn))
->getQuery()
->getSingleScalarResult();
}
return $totalSize - $startOffset;
} | php | private function getTotalNumberOfEntities($entity, $startOffset)
{
$objectManager = $this->getObjectManager($entity);
$repository = $objectManager->getRepository($entity);
if ($repository instanceof DocumentRepository) {
$totalSize = $repository->createQueryBuilder()
->getQuery()
->count();
} else {
$dataStoreMetadata = $objectManager->getClassMetadata($entity);
$identifierFieldNames = $dataStoreMetadata->getIdentifierFieldNames();
if (!count($identifierFieldNames)) {
throw new \Exception(sprintf('No primary key found for entity %s', $entity));
}
$countableColumn = reset($identifierFieldNames);
/** @var EntityRepository $repository */
$totalSize = $repository->createQueryBuilder('size')
->select(sprintf('count(size.%s)', $countableColumn))
->getQuery()
->getSingleScalarResult();
}
return $totalSize - $startOffset;
} | [
"private",
"function",
"getTotalNumberOfEntities",
"(",
"$",
"entity",
",",
"$",
"startOffset",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
"$",
"entity",
")",
";",
"$",
"repository",
"=",
"$",
"objectManager",
"->",
"get... | Get the total number of entities in a repository
@param string $entity
@param int $startOffset
@return int
@throws \Exception if no primary key was found for the given entity | [
"Get",
"the",
"total",
"number",
"of",
"entities",
"in",
"a",
"repository"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/SynchronizeIndexCommand.php#L177-L205 |
floriansemm/SolrBundle | DependencyInjection/Compiler/AddSolariumPluginsPass.php | AddSolariumPluginsPass.process | public function process(ContainerBuilder $container)
{
$plugins = $container->findTaggedServiceIds('solarium.client.plugin');
$clientBuilder = $container->getDefinition('solr.client.adapter.builder');
foreach ($plugins as $service => $definition) {
$clientBuilder->addMethodCall(
'addPlugin',
array(
$definition[0]['plugin-name'],
new Reference($service)
)
);
}
} | php | public function process(ContainerBuilder $container)
{
$plugins = $container->findTaggedServiceIds('solarium.client.plugin');
$clientBuilder = $container->getDefinition('solr.client.adapter.builder');
foreach ($plugins as $service => $definition) {
$clientBuilder->addMethodCall(
'addPlugin',
array(
$definition[0]['plugin-name'],
new Reference($service)
)
);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"plugins",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'solarium.client.plugin'",
")",
";",
"$",
"clientBuilder",
"=",
"$",
"container",
"->",
"getDefinition"... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/DependencyInjection/Compiler/AddSolariumPluginsPass.php#L17-L31 |
floriansemm/SolrBundle | Doctrine/Mapper/MetaInformation.php | MetaInformation.getEntityId | public function getEntityId()
{
if ($this->entity !== null && $this->entity->getId()) {
return $this->entity->getId();
}
return $this->entityId;
} | php | public function getEntityId()
{
if ($this->entity !== null && $this->entity->getId()) {
return $this->entity->getId();
}
return $this->entityId;
} | [
"public",
"function",
"getEntityId",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entity",
"!==",
"null",
"&&",
"$",
"this",
"->",
"entity",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"entity",
"->",
"getId",
"(",
")",
";",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformation.php#L86-L93 |
floriansemm/SolrBundle | Doctrine/Mapper/MetaInformation.php | MetaInformation.hasField | public function hasField($fieldName)
{
$fields = array_filter($this->fields, function(Field $field) use ($fieldName) {
return $field->name == $fieldName || $field->getNameWithAlias() == $fieldName;
});
if (count($fields) == 0) {
return false;
}
return true;
} | php | public function hasField($fieldName)
{
$fields = array_filter($this->fields, function(Field $field) use ($fieldName) {
return $field->name == $fieldName || $field->getNameWithAlias() == $fieldName;
});
if (count($fields) == 0) {
return false;
}
return true;
} | [
"public",
"function",
"hasField",
"(",
"$",
"fieldName",
")",
"{",
"$",
"fields",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"fields",
",",
"function",
"(",
"Field",
"$",
"field",
")",
"use",
"(",
"$",
"fieldName",
")",
"{",
"return",
"$",
"field",
... | @param string $fieldName
@return boolean | [
"@param",
"string",
"$fieldName"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformation.php#L188-L199 |
floriansemm/SolrBundle | Doctrine/Mapper/MetaInformation.php | MetaInformation.setFieldValue | public function setFieldValue($fieldName, $value)
{
if ($this->hasField($fieldName) == false) {
throw new SolrMappingException(sprintf('Field %s does not exist', $fieldName));
}
$field = $this->getField($fieldName);
$field->value = $value;
} | php | public function setFieldValue($fieldName, $value)
{
if ($this->hasField($fieldName) == false) {
throw new SolrMappingException(sprintf('Field %s does not exist', $fieldName));
}
$field = $this->getField($fieldName);
$field->value = $value;
} | [
"public",
"function",
"setFieldValue",
"(",
"$",
"fieldName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasField",
"(",
"$",
"fieldName",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"SolrMappingException",
"(",
"sprintf",
"(",
"'Field... | @param string $fieldName
@param string $value
@throws SolrMappingException if $fieldName does not exist | [
"@param",
"string",
"$fieldName",
"@param",
"string",
"$value"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformation.php#L207-L215 |
floriansemm/SolrBundle | Doctrine/Mapper/MetaInformation.php | MetaInformation.getField | public function getField($fieldName)
{
if ($fieldName == '') {
throw new SolrMappingException('$fieldName must not be empty');
}
if (!$this->hasField($fieldName)) {
return null;
}
$fields = array_filter($this->fields, function(Field $field) use ($fieldName) {
return $field->name == $fieldName || $field->getNameWithAlias() == $fieldName;
});
return array_pop($fields);
} | php | public function getField($fieldName)
{
if ($fieldName == '') {
throw new SolrMappingException('$fieldName must not be empty');
}
if (!$this->hasField($fieldName)) {
return null;
}
$fields = array_filter($this->fields, function(Field $field) use ($fieldName) {
return $field->name == $fieldName || $field->getNameWithAlias() == $fieldName;
});
return array_pop($fields);
} | [
"public",
"function",
"getField",
"(",
"$",
"fieldName",
")",
"{",
"if",
"(",
"$",
"fieldName",
"==",
"''",
")",
"{",
"throw",
"new",
"SolrMappingException",
"(",
"'$fieldName must not be empty'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasField... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformation.php#L220-L235 |
floriansemm/SolrBundle | Doctrine/Hydration/IndexHydrator.php | IndexHydrator.hydrate | public function hydrate($document, MetaInformationInterface $metaInformation)
{
$sourceTargetEntity = $metaInformation->getEntity();
$targetEntity = clone $sourceTargetEntity;
$metaInformation->setEntity($targetEntity);
return $this->valueHydrator->hydrate($document, $metaInformation);
} | php | public function hydrate($document, MetaInformationInterface $metaInformation)
{
$sourceTargetEntity = $metaInformation->getEntity();
$targetEntity = clone $sourceTargetEntity;
$metaInformation->setEntity($targetEntity);
return $this->valueHydrator->hydrate($document, $metaInformation);
} | [
"public",
"function",
"hydrate",
"(",
"$",
"document",
",",
"MetaInformationInterface",
"$",
"metaInformation",
")",
"{",
"$",
"sourceTargetEntity",
"=",
"$",
"metaInformation",
"->",
"getEntity",
"(",
")",
";",
"$",
"targetEntity",
"=",
"clone",
"$",
"sourceTar... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/IndexHydrator.php#L28-L36 |
floriansemm/SolrBundle | Doctrine/Hydration/DoctrineValueHydrator.php | DoctrineValueHydrator.mapValue | public function mapValue($fieldName, $value, MetaInformationInterface $metaInformation)
{
if (is_array($value)) {
return false;
}
// is object with getter
if ($metaInformation->getField($fieldName) && $metaInformation->getField($fieldName)->getter) {
return false;
}
return true;
} | php | public function mapValue($fieldName, $value, MetaInformationInterface $metaInformation)
{
if (is_array($value)) {
return false;
}
// is object with getter
if ($metaInformation->getField($fieldName) && $metaInformation->getField($fieldName)->getter) {
return false;
}
return true;
} | [
"public",
"function",
"mapValue",
"(",
"$",
"fieldName",
",",
"$",
"value",
",",
"MetaInformationInterface",
"$",
"metaInformation",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"// is object with getter",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/DoctrineValueHydrator.php#L13-L25 |
floriansemm/SolrBundle | Doctrine/ORM/Listener/EntityIndexerSubscriber.php | EntityIndexerSubscriber.emptyCollections | private function emptyCollections($object)
{
$deepcopy = new DeepCopy();
$deepcopy->addFilter(new DoctrineEmptyCollectionFilter(), new PropertyTypeMatcher('Doctrine\Common\Collections\Collection'));
return $deepcopy->copy($object);
} | php | private function emptyCollections($object)
{
$deepcopy = new DeepCopy();
$deepcopy->addFilter(new DoctrineEmptyCollectionFilter(), new PropertyTypeMatcher('Doctrine\Common\Collections\Collection'));
return $deepcopy->copy($object);
} | [
"private",
"function",
"emptyCollections",
"(",
"$",
"object",
")",
"{",
"$",
"deepcopy",
"=",
"new",
"DeepCopy",
"(",
")",
";",
"$",
"deepcopy",
"->",
"addFilter",
"(",
"new",
"DoctrineEmptyCollectionFilter",
"(",
")",
",",
"new",
"PropertyTypeMatcher",
"(",
... | @param object $object
@return object | [
"@param",
"object",
"$object"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/ORM/Listener/EntityIndexerSubscriber.php#L98-L104 |
floriansemm/SolrBundle | DataCollector/RequestCollector.php | RequestCollector.parseQuery | public function parseQuery($request)
{
list($endpoint, $params) = explode('?', $request['request']['uri']);
$request['endpoint'] = $endpoint;
$request['params'] = $params;
$request['method'] = $request['request']['method'];
$request['raw_data'] = $request['request']['raw_data'];
if (class_exists(VarCloner::class)) {
$varCloner = new VarCloner();
parse_str($params, $stub);
$request['stub'] = Kernel::VERSION_ID >= 30200 ? $varCloner->cloneVar($stub) : $stub;
}
return $request;
} | php | public function parseQuery($request)
{
list($endpoint, $params) = explode('?', $request['request']['uri']);
$request['endpoint'] = $endpoint;
$request['params'] = $params;
$request['method'] = $request['request']['method'];
$request['raw_data'] = $request['request']['raw_data'];
if (class_exists(VarCloner::class)) {
$varCloner = new VarCloner();
parse_str($params, $stub);
$request['stub'] = Kernel::VERSION_ID >= 30200 ? $varCloner->cloneVar($stub) : $stub;
}
return $request;
} | [
"public",
"function",
"parseQuery",
"(",
"$",
"request",
")",
"{",
"list",
"(",
"$",
"endpoint",
",",
"$",
"params",
")",
"=",
"explode",
"(",
"'?'",
",",
"$",
"request",
"[",
"'request'",
"]",
"[",
"'uri'",
"]",
")",
";",
"$",
"request",
"[",
"'en... | @param array $request
@return array | [
"@param",
"array",
"$request"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/DataCollector/RequestCollector.php#L73-L90 |
floriansemm/SolrBundle | Query/FindByDocumentNameQuery.php | FindByDocumentNameQuery.getQuery | public function getQuery()
{
$documentName = $this->documentName;
if ($documentName == null) {
throw new QueryException('documentName should not be null');
}
$documentLimitation = $this->createFilterQuery('id')->setQuery(sprintf('id:%s_*', $documentName));
$this->addFilterQuery($documentLimitation);
$this->setQuery('*:*');
return parent::getQuery();
} | php | public function getQuery()
{
$documentName = $this->documentName;
if ($documentName == null) {
throw new QueryException('documentName should not be null');
}
$documentLimitation = $this->createFilterQuery('id')->setQuery(sprintf('id:%s_*', $documentName));
$this->addFilterQuery($documentLimitation);
$this->setQuery('*:*');
return parent::getQuery();
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"documentName",
"=",
"$",
"this",
"->",
"documentName",
";",
"if",
"(",
"$",
"documentName",
"==",
"null",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"'documentName should not be null'",
")",
";",
"... | @return string
@throws QueryException if documentName is null | [
"@return",
"string"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/FindByDocumentNameQuery.php#L32-L46 |
floriansemm/SolrBundle | Client/Solarium/SolariumClientBuilder.php | SolariumClientBuilder.build | public function build()
{
$settings = [];
foreach ($this->settings as $name => $options) {
if (isset($options['dsn'])) {
unset(
$options['scheme'],
$options['host'],
$options['port'],
$options['path']
);
$parsedDsn = parse_url($options['dsn']);
unset($options['dsn']);
if ($parsedDsn) {
$options['scheme'] = isset($parsedDsn['scheme']) ? $parsedDsn['scheme'] : 'http';
if (isset($parsedDsn['host'])) {
$options['host'] = $parsedDsn['host'];
}
if (isset($parsedDsn['user'])) {
$auth = $parsedDsn['user'] . (isset($parsedDsn['pass']) ? ':' . $parsedDsn['pass'] : '');
$options['host'] = $auth . '@' . $options['host'];
}
$options['port'] = isset($parsedDsn['port']) ? $parsedDsn['port'] : 80;
$options['path'] = isset($parsedDsn['path']) ? $parsedDsn['path'] : '';
}
}
$settings[$name] = $options;
}
$solariumClient = new Client(array('endpoint' => $settings), $this->eventDispatcher);
foreach ($this->plugins as $pluginName => $plugin) {
$solariumClient->registerPlugin($pluginName, $plugin);
}
return $solariumClient;
} | php | public function build()
{
$settings = [];
foreach ($this->settings as $name => $options) {
if (isset($options['dsn'])) {
unset(
$options['scheme'],
$options['host'],
$options['port'],
$options['path']
);
$parsedDsn = parse_url($options['dsn']);
unset($options['dsn']);
if ($parsedDsn) {
$options['scheme'] = isset($parsedDsn['scheme']) ? $parsedDsn['scheme'] : 'http';
if (isset($parsedDsn['host'])) {
$options['host'] = $parsedDsn['host'];
}
if (isset($parsedDsn['user'])) {
$auth = $parsedDsn['user'] . (isset($parsedDsn['pass']) ? ':' . $parsedDsn['pass'] : '');
$options['host'] = $auth . '@' . $options['host'];
}
$options['port'] = isset($parsedDsn['port']) ? $parsedDsn['port'] : 80;
$options['path'] = isset($parsedDsn['path']) ? $parsedDsn['path'] : '';
}
}
$settings[$name] = $options;
}
$solariumClient = new Client(array('endpoint' => $settings), $this->eventDispatcher);
foreach ($this->plugins as $pluginName => $plugin) {
$solariumClient->registerPlugin($pluginName, $plugin);
}
return $solariumClient;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"settings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'dsn'",
"]",
")",
... | {@inheritdoc}
@return Client | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Client/Solarium/SolariumClientBuilder.php#L54-L91 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getPropertiesByType | private function getPropertiesByType($entity, $type)
{
$properties = $this->readClassProperties($entity);
$fields = [];
foreach ($properties as $property) {
$annotation = $this->reader->getPropertyAnnotation($property, $type);
if (null === $annotation) {
continue;
}
$property->setAccessible(true);
$annotation->value = $property->getValue($entity);
$annotation->name = $property->getName();
$fields[] = $annotation;
}
return $fields;
} | php | private function getPropertiesByType($entity, $type)
{
$properties = $this->readClassProperties($entity);
$fields = [];
foreach ($properties as $property) {
$annotation = $this->reader->getPropertyAnnotation($property, $type);
if (null === $annotation) {
continue;
}
$property->setAccessible(true);
$annotation->value = $property->getValue($entity);
$annotation->name = $property->getName();
$fields[] = $annotation;
}
return $fields;
} | [
"private",
"function",
"getPropertiesByType",
"(",
"$",
"entity",
",",
"$",
"type",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"readClassProperties",
"(",
"$",
"entity",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"prope... | reads the entity and returns a set of annotations
@param object $entity
@param string $type
@return Annotation[] | [
"reads",
"the",
"entity",
"and",
"returns",
"a",
"set",
"of",
"annotations"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L43-L63 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getParentProperties | private function getParentProperties(\ReflectionClass $reflectionClass)
{
$parent = $reflectionClass->getParentClass();
if ($parent != null) {
return array_merge($reflectionClass->getProperties(), $this->getParentProperties($parent));
}
return $reflectionClass->getProperties();
} | php | private function getParentProperties(\ReflectionClass $reflectionClass)
{
$parent = $reflectionClass->getParentClass();
if ($parent != null) {
return array_merge($reflectionClass->getProperties(), $this->getParentProperties($parent));
}
return $reflectionClass->getProperties();
} | [
"private",
"function",
"getParentProperties",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"$",
"parent",
"=",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"!=",
"null",
")",
"{",
"return",
"arra... | @param \ReflectionClass $reflectionClass
@return \ReflectionProperty[] | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L70-L78 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getMethods | public function getMethods($entity)
{
$reflectionClass = new \ReflectionClass($entity);
$methods = [];
foreach ($reflectionClass->getMethods() as $method) {
/** @var Field $annotation */
$annotation = $this->reader->getMethodAnnotation($method, self::FIELD_CLASS);
if ($annotation === null) {
continue;
}
$annotation->value = $method->invoke($entity);
if ($annotation->name == '') {
throw new SolrMappingException(sprintf('Please configure a field-name for method "%s" with field-annotation in class "%s"', $method->getName(), get_class($entity)));
}
$methods[] = $annotation;
}
return $methods;
} | php | public function getMethods($entity)
{
$reflectionClass = new \ReflectionClass($entity);
$methods = [];
foreach ($reflectionClass->getMethods() as $method) {
/** @var Field $annotation */
$annotation = $this->reader->getMethodAnnotation($method, self::FIELD_CLASS);
if ($annotation === null) {
continue;
}
$annotation->value = $method->invoke($entity);
if ($annotation->name == '') {
throw new SolrMappingException(sprintf('Please configure a field-name for method "%s" with field-annotation in class "%s"', $method->getName(), get_class($entity)));
}
$methods[] = $annotation;
}
return $methods;
} | [
"public",
"function",
"getMethods",
"(",
"$",
"entity",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entity",
")",
";",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"... | @param object $entity
@return array
@throws \ReflectionException | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L97-L120 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getEntityBoost | public function getEntityBoost($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if (!$annotation instanceof Document) {
return 0;
}
$boostValue = $annotation->getBoost();
if (!is_numeric($boostValue)) {
throw new AnnotationReaderException(sprintf('Invalid boost value "%s" in class "%s" configured', $boostValue, get_class($entity)));
}
if ($boostValue === 0) {
return null;
}
return $boostValue;
} | php | public function getEntityBoost($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if (!$annotation instanceof Document) {
return 0;
}
$boostValue = $annotation->getBoost();
if (!is_numeric($boostValue)) {
throw new AnnotationReaderException(sprintf('Invalid boost value "%s" in class "%s" configured', $boostValue, get_class($entity)));
}
if ($boostValue === 0) {
return null;
}
return $boostValue;
} | [
"public",
"function",
"getEntityBoost",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"DOCUMENT_CLASS",
")",
";",
"if",
"(",
"!",
"$",
"annotation",
"instanceof",
"Docu... | @param object $entity
@return number
@throws AnnotationReaderException if the boost value is not numeric | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L129-L147 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getDocumentIndex | public function getDocumentIndex($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if (!$annotation instanceof Document) {
return null;
}
$indexHandler = $annotation->indexHandler;
if ($indexHandler != '' && method_exists($entity, $indexHandler)) {
return $entity->$indexHandler();
}
return $annotation->getIndex();
} | php | public function getDocumentIndex($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if (!$annotation instanceof Document) {
return null;
}
$indexHandler = $annotation->indexHandler;
if ($indexHandler != '' && method_exists($entity, $indexHandler)) {
return $entity->$indexHandler();
}
return $annotation->getIndex();
} | [
"public",
"function",
"getDocumentIndex",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"DOCUMENT_CLASS",
")",
";",
"if",
"(",
"!",
"$",
"annotation",
"instanceof",
"Do... | @param object $entity
@return string | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L154-L167 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getIdentifier | public function getIdentifier($entity)
{
$id = $this->getPropertiesByType($entity, self::FIELD_IDENTIFIER_CLASS);
if (count($id) == 0) {
throw new AnnotationReaderException('no identifer declared in entity ' . get_class($entity));
}
return reset($id);
} | php | public function getIdentifier($entity)
{
$id = $this->getPropertiesByType($entity, self::FIELD_IDENTIFIER_CLASS);
if (count($id) == 0) {
throw new AnnotationReaderException('no identifer declared in entity ' . get_class($entity));
}
return reset($id);
} | [
"public",
"function",
"getIdentifier",
"(",
"$",
"entity",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getPropertiesByType",
"(",
"$",
"entity",
",",
"self",
"::",
"FIELD_IDENTIFIER_CLASS",
")",
";",
"if",
"(",
"count",
"(",
"$",
"id",
")",
"==",
"0"... | @param object $entity
@return Id
@throws AnnotationReaderException if given $entity has no identifier | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L176-L185 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getRepository | public function getRepository($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if ($annotation instanceof Document) {
return $annotation->repository;
}
return '';
} | php | public function getRepository($entity)
{
$annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
if ($annotation instanceof Document) {
return $annotation->repository;
}
return '';
} | [
"public",
"function",
"getRepository",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"DOCUMENT_CLASS",
")",
";",
"if",
"(",
"$",
"annotation",
"instanceof",
"Document",
... | @param object $entity
@return string classname of repository | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L192-L201 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getFieldMapping | public function getFieldMapping($entity)
{
$fields = $this->getPropertiesByType($entity, self::FIELD_CLASS);
$mapping = [];
foreach ($fields as $field) {
$mapping[$field->getNameWithAlias()] = $field->name;
}
$id = $this->getIdentifier($entity);
$mapping['id'] = $id->name;
return $mapping;
} | php | public function getFieldMapping($entity)
{
$fields = $this->getPropertiesByType($entity, self::FIELD_CLASS);
$mapping = [];
foreach ($fields as $field) {
$mapping[$field->getNameWithAlias()] = $field->name;
}
$id = $this->getIdentifier($entity);
$mapping['id'] = $id->name;
return $mapping;
} | [
"public",
"function",
"getFieldMapping",
"(",
"$",
"entity",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getPropertiesByType",
"(",
"$",
"entity",
",",
"self",
"::",
"FIELD_CLASS",
")",
";",
"$",
"mapping",
"=",
"[",
"]",
";",
"foreach",
"(",
"$"... | returns all fields and field for idendification
@param object $entity
@return array | [
"returns",
"all",
"fields",
"and",
"field",
"for",
"idendification"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L210-L223 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.hasDocumentDeclaration | public function hasDocumentDeclaration($entity)
{
if ($rootDocument = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS)) {
return true;
}
if ($this->isNested($entity)) {
return true;
}
return false;
} | php | public function hasDocumentDeclaration($entity)
{
if ($rootDocument = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS)) {
return true;
}
if ($this->isNested($entity)) {
return true;
}
return false;
} | [
"public",
"function",
"hasDocumentDeclaration",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"rootDocument",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"DOCUMENT_CLASS",
")",
")",
"{",
"return",
"true",
";",
"}",
... | @param object $entity
@return boolean | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L230-L241 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getSynchronizationCallback | public function getSynchronizationCallback($entity)
{
$annotation = $this->getClassAnnotation($entity, self::SYNCHRONIZATION_FILTER_CLASS);
if (!$annotation) {
return '';
}
return $annotation->callback;
} | php | public function getSynchronizationCallback($entity)
{
$annotation = $this->getClassAnnotation($entity, self::SYNCHRONIZATION_FILTER_CLASS);
if (!$annotation) {
return '';
}
return $annotation->callback;
} | [
"public",
"function",
"getSynchronizationCallback",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"SYNCHRONIZATION_FILTER_CLASS",
")",
";",
"if",
"(",
"!",
"$",
"annotation... | @param string $entity
@return string | [
"@param",
"string",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L248-L257 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.isOrm | public function isOrm($entity)
{
$annotation = $this->getClassAnnotation($entity, 'Doctrine\ORM\Mapping\Entity');
if ($annotation === null) {
return false;
}
return true;
} | php | public function isOrm($entity)
{
$annotation = $this->getClassAnnotation($entity, 'Doctrine\ORM\Mapping\Entity');
if ($annotation === null) {
return false;
}
return true;
} | [
"public",
"function",
"isOrm",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"'Doctrine\\ORM\\Mapping\\Entity'",
")",
";",
"if",
"(",
"$",
"annotation",
"===",
"null",
")",
"{",
"ret... | @param object $entity
@return bool | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L264-L273 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.isOdm | public function isOdm($entity)
{
$annotation = $this->getClassAnnotation($entity, 'Doctrine\ODM\MongoDB\Mapping\Annotations\Document');
if ($annotation === null) {
return false;
}
return true;
} | php | public function isOdm($entity)
{
$annotation = $this->getClassAnnotation($entity, 'Doctrine\ODM\MongoDB\Mapping\Annotations\Document');
if ($annotation === null) {
return false;
}
return true;
} | [
"public",
"function",
"isOdm",
"(",
"$",
"entity",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"'Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'",
")",
";",
"if",
"(",
"$",
"annotation",
"===",
"nul... | @param object $entity
@return bool | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L280-L289 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.isNested | public function isNested($entity)
{
if ($nestedDocument = $this->getClassAnnotation($entity, self::DOCUMENT_NESTED_CLASS)) {
return true;
}
return false;
} | php | public function isNested($entity)
{
if ($nestedDocument = $this->getClassAnnotation($entity, self::DOCUMENT_NESTED_CLASS)) {
return true;
}
return false;
} | [
"public",
"function",
"isNested",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"nestedDocument",
"=",
"$",
"this",
"->",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"self",
"::",
"DOCUMENT_NESTED_CLASS",
")",
")",
"{",
"return",
"true",
";",
"}",
"re... | @param object $entity
@return bool | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L296-L303 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.getClassAnnotation | private function getClassAnnotation($entity, $annotationName)
{
$reflectionClass = new \ReflectionClass($entity);
$annotation = $this->reader->getClassAnnotation($reflectionClass, $annotationName);
if ($annotation === null && $reflectionClass->getParentClass()) {
$annotation = $this->reader->getClassAnnotation($reflectionClass->getParentClass(), $annotationName);
}
return $annotation;
} | php | private function getClassAnnotation($entity, $annotationName)
{
$reflectionClass = new \ReflectionClass($entity);
$annotation = $this->reader->getClassAnnotation($reflectionClass, $annotationName);
if ($annotation === null && $reflectionClass->getParentClass()) {
$annotation = $this->reader->getClassAnnotation($reflectionClass->getParentClass(), $annotationName);
}
return $annotation;
} | [
"private",
"function",
"getClassAnnotation",
"(",
"$",
"entity",
",",
"$",
"annotationName",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entity",
")",
";",
"$",
"annotation",
"=",
"$",
"this",
"->",
"reader",
"->",
"ge... | @param string $entity
@param string $annotationName
@return Annotation|null | [
"@param",
"string",
"$entity",
"@param",
"string",
"$annotationName"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L311-L322 |
floriansemm/SolrBundle | Doctrine/Annotation/AnnotationReader.php | AnnotationReader.readClassProperties | private function readClassProperties($entity)
{
$className = get_class($entity);
if (isset($this->entityProperties[$className])) {
return $this->entityProperties[$className];
}
$reflectionClass = new \ReflectionClass($entity);
$inheritedProperties = array_merge($this->getParentProperties($reflectionClass), $reflectionClass->getProperties());
$properties = [];
foreach ($inheritedProperties as $property) {
$properties[$property->getName()] = $property;
}
$this->entityProperties[$className] = $properties;
return $properties;
} | php | private function readClassProperties($entity)
{
$className = get_class($entity);
if (isset($this->entityProperties[$className])) {
return $this->entityProperties[$className];
}
$reflectionClass = new \ReflectionClass($entity);
$inheritedProperties = array_merge($this->getParentProperties($reflectionClass), $reflectionClass->getProperties());
$properties = [];
foreach ($inheritedProperties as $property) {
$properties[$property->getName()] = $property;
}
$this->entityProperties[$className] = $properties;
return $properties;
} | [
"private",
"function",
"readClassProperties",
"(",
"$",
"entity",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityProperties",
"[",
"$",
"className",
"]",
")",
")",
"{",
"re... | @param object $entity
@return \ReflectionProperty[] | [
"@param",
"object",
"$entity"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Annotation/AnnotationReader.php#L329-L347 |
floriansemm/SolrBundle | Command/ClearIndexCommand.php | ClearIndexCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$solr = $this->getContainer()->get('solr.client');
try {
$solr->clearIndex();
} catch (SolrException $e) {
$output->writeln(sprintf('A error occurs: %s', $e->getMessage()));
}
$output->writeln('<info>Index successful cleared.</info>');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$solr = $this->getContainer()->get('solr.client');
try {
$solr->clearIndex();
} catch (SolrException $e) {
$output->writeln(sprintf('A error occurs: %s', $e->getMessage()));
}
$output->writeln('<info>Index successful cleared.</info>');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"solr",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'solr.client'",
")",
";",
"try",
"{",
"$",
"solr",... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Command/ClearIndexCommand.php#L30-L41 |
floriansemm/SolrBundle | Query/SolrQuery.php | SolrQuery.addField | public function addField($field)
{
$entityFieldNames = array_flip($this->mappedFields);
if (array_key_exists($field, $entityFieldNames)) {
parent::addField($entityFieldNames[$field]);
}
return $this;
} | php | public function addField($field)
{
$entityFieldNames = array_flip($this->mappedFields);
if (array_key_exists($field, $entityFieldNames)) {
parent::addField($entityFieldNames[$field]);
}
return $this;
} | [
"public",
"function",
"addField",
"(",
"$",
"field",
")",
"{",
"$",
"entityFieldNames",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"mappedFields",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"entityFieldNames",
")",
")",
"{",
"p... | @param string $field
@return SolrQuery | [
"@param",
"string",
"$field"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/SolrQuery.php#L163-L171 |
floriansemm/SolrBundle | Query/SolrQuery.php | SolrQuery.querifyFieldValue | private function querifyFieldValue($fieldValue)
{
if (is_array($fieldValue) && count($fieldValue) > 1) {
sort($fieldValue);
$quoted = array_map(function($value) {
return '"'. $value .'"';
}, $fieldValue);
$fieldValue = implode(' TO ', $quoted);
$fieldValue = '['. $fieldValue . ']';
return $fieldValue;
}
if (is_array($fieldValue) && count($fieldValue) === 1) {
$fieldValue = array_pop($fieldValue);
}
if ($this->useWildcards) {
$fieldValue = '*' . $fieldValue . '*';
}
$termParts = explode(' ', $fieldValue);
if (count($termParts) > 1) {
$fieldValue = '"'.$fieldValue.'"';
}
return $fieldValue;
} | php | private function querifyFieldValue($fieldValue)
{
if (is_array($fieldValue) && count($fieldValue) > 1) {
sort($fieldValue);
$quoted = array_map(function($value) {
return '"'. $value .'"';
}, $fieldValue);
$fieldValue = implode(' TO ', $quoted);
$fieldValue = '['. $fieldValue . ']';
return $fieldValue;
}
if (is_array($fieldValue) && count($fieldValue) === 1) {
$fieldValue = array_pop($fieldValue);
}
if ($this->useWildcards) {
$fieldValue = '*' . $fieldValue . '*';
}
$termParts = explode(' ', $fieldValue);
if (count($termParts) > 1) {
$fieldValue = '"'.$fieldValue.'"';
}
return $fieldValue;
} | [
"private",
"function",
"querifyFieldValue",
"(",
"$",
"fieldValue",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"fieldValue",
")",
"&&",
"count",
"(",
"$",
"fieldValue",
")",
">",
"1",
")",
"{",
"sort",
"(",
"$",
"fieldValue",
")",
";",
"$",
"quoted",
... | Transforms array to string representation and adds quotes
@param string $fieldValue
@return string | [
"Transforms",
"array",
"to",
"string",
"representation",
"and",
"adds",
"quotes"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/SolrQuery.php#L255-L284 |
floriansemm/SolrBundle | Repository/Repository.php | Repository.find | public function find($id)
{
$documentKey = $this->metaInformation->getDocumentName() . '_' . $id;
$query = new FindByIdentifierQuery();
$query->setIndex($this->metaInformation->getIndex());
$query->setDocumentKey($documentKey);
$query->setEntity($this->metaInformation->getEntity());
$query->setSolr($this->solr);
$query->setHydrationMode($this->hydrationMode);
$found = $this->solr->query($query);
if (count($found) == 0) {
return null;
}
return array_pop($found);
} | php | public function find($id)
{
$documentKey = $this->metaInformation->getDocumentName() . '_' . $id;
$query = new FindByIdentifierQuery();
$query->setIndex($this->metaInformation->getIndex());
$query->setDocumentKey($documentKey);
$query->setEntity($this->metaInformation->getEntity());
$query->setSolr($this->solr);
$query->setHydrationMode($this->hydrationMode);
$found = $this->solr->query($query);
if (count($found) == 0) {
return null;
}
return array_pop($found);
} | [
"public",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"documentKey",
"=",
"$",
"this",
"->",
"metaInformation",
"->",
"getDocumentName",
"(",
")",
".",
"'_'",
".",
"$",
"id",
";",
"$",
"query",
"=",
"new",
"FindByIdentifierQuery",
"(",
")",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Repository/Repository.php#L48-L65 |
floriansemm/SolrBundle | Repository/Repository.php | Repository.findAll | public function findAll()
{
$query = new FindByDocumentNameQuery();
$query->setRows(1000000);
$query->setDocumentName($this->metaInformation->getDocumentName());
$query->setIndex($this->metaInformation->getIndex());
$query->setEntity($this->metaInformation->getEntity());
$query->setSolr($this->solr);
$query->setHydrationMode($this->hydrationMode);
return $this->solr->query($query);
} | php | public function findAll()
{
$query = new FindByDocumentNameQuery();
$query->setRows(1000000);
$query->setDocumentName($this->metaInformation->getDocumentName());
$query->setIndex($this->metaInformation->getIndex());
$query->setEntity($this->metaInformation->getEntity());
$query->setSolr($this->solr);
$query->setHydrationMode($this->hydrationMode);
return $this->solr->query($query);
} | [
"public",
"function",
"findAll",
"(",
")",
"{",
"$",
"query",
"=",
"new",
"FindByDocumentNameQuery",
"(",
")",
";",
"$",
"query",
"->",
"setRows",
"(",
"1000000",
")",
";",
"$",
"query",
"->",
"setDocumentName",
"(",
"$",
"this",
"->",
"metaInformation",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Repository/Repository.php#L70-L81 |
floriansemm/SolrBundle | Repository/Repository.php | Repository.findBy | public function findBy(array $args)
{
$query = $this->solr->createQuery($this->metaInformation->getEntity());
$query->setHydrationMode($this->hydrationMode);
$query->setRows(100000);
$query->setUseAndOperator(true);
$query->addSearchTerm('id', $this->metaInformation->getDocumentName() . '_*');
$query->setQueryDefaultField('id');
$helper = $query->getHelper();
foreach ($args as $fieldName => $fieldValue) {
$fieldValue = $helper->escapeTerm($fieldValue);
$query->addSearchTerm($fieldName, $fieldValue);
}
return $this->solr->query($query);
} | php | public function findBy(array $args)
{
$query = $this->solr->createQuery($this->metaInformation->getEntity());
$query->setHydrationMode($this->hydrationMode);
$query->setRows(100000);
$query->setUseAndOperator(true);
$query->addSearchTerm('id', $this->metaInformation->getDocumentName() . '_*');
$query->setQueryDefaultField('id');
$helper = $query->getHelper();
foreach ($args as $fieldName => $fieldValue) {
$fieldValue = $helper->escapeTerm($fieldValue);
$query->addSearchTerm($fieldName, $fieldValue);
}
return $this->solr->query($query);
} | [
"public",
"function",
"findBy",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"solr",
"->",
"createQuery",
"(",
"$",
"this",
"->",
"metaInformation",
"->",
"getEntity",
"(",
")",
")",
";",
"$",
"query",
"->",
"setHydrationM... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Repository/Repository.php#L86-L103 |
floriansemm/SolrBundle | Doctrine/Hydration/PropertyAccessor/PrivatePropertyAccessor.php | PrivatePropertyAccessor.setValue | public function setValue($targetObject, $value)
{
$this->classProperty->setAccessible(true);
$this->classProperty->setValue($targetObject, $value);
} | php | public function setValue($targetObject, $value)
{
$this->classProperty->setAccessible(true);
$this->classProperty->setValue($targetObject, $value);
} | [
"public",
"function",
"setValue",
"(",
"$",
"targetObject",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"classProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"this",
"->",
"classProperty",
"->",
"setValue",
"(",
"$",
"targetObject",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/PropertyAccessor/PrivatePropertyAccessor.php#L24-L28 |
Bogardo/Mailgun | src/Service.php | Service.send | public function send($view, array $data, Closure $callback)
{
return $this->mailer->send($view, $data, $callback);
} | php | public function send($view, array $data, Closure $callback)
{
return $this->mailer->send($view, $data, $callback);
} | [
"public",
"function",
"send",
"(",
"$",
"view",
",",
"array",
"$",
"data",
",",
"Closure",
"$",
"callback",
")",
"{",
"return",
"$",
"this",
"->",
"mailer",
"->",
"send",
"(",
"$",
"view",
",",
"$",
"data",
",",
"$",
"callback",
")",
";",
"}"
] | @param string $view
@param array $data
@param \Closure $callback
@return \Bogardo\Mailgun\Http\Response | [
"@param",
"string",
"$view",
"@param",
"array",
"$data",
"@param",
"\\",
"Closure",
"$callback"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Service.php#L57-L60 |
Bogardo/Mailgun | src/Service.php | Service.later | public function later($time, $view, array $data, Closure $callback)
{
return $this->mailer->later($time, $view, $data, $callback);
} | php | public function later($time, $view, array $data, Closure $callback)
{
return $this->mailer->later($time, $view, $data, $callback);
} | [
"public",
"function",
"later",
"(",
"$",
"time",
",",
"$",
"view",
",",
"array",
"$",
"data",
",",
"Closure",
"$",
"callback",
")",
"{",
"return",
"$",
"this",
"->",
"mailer",
"->",
"later",
"(",
"$",
"time",
",",
"$",
"view",
",",
"$",
"data",
"... | @param int|array $time
@param string $view
@param array $data
@param \Closure $callback
@return \Bogardo\Mailgun\Http\Response | [
"@param",
"int|array",
"$time",
"@param",
"string",
"$view",
"@param",
"array",
"$data",
"@param",
"\\",
"Closure",
"$callback"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Service.php#L81-L84 |
Bogardo/Mailgun | src/MailgunServiceProvider.php | MailgunServiceProvider.register | public function register()
{
/** @var \Illuminate\Config\Repository $config */
$config = $this->app->make('config');
/**
* Register main Mailgun service
*/
$this->app->bind('mailgun', function () use ($config) {
$clientAdapter = $this->app->make('mailgun.client');
$mg = new MailgunApi(
$config->get('mailgun.api_key'),
$clientAdapter,
$config->get('mailgun.api.endpoint')
);
$mg->setApiVersion($config->get('mailgun.api.version'));
$mg->setSslEnabled($config->get('mailgun.api.ssl', true));
return new Service($mg, $this->app->make('view'), $config);
});
/**
* Register the public Mailgun service
*/
$this->app->bind('mailgun.public', function () use ($config) {
$clientAdapter = $this->app->make('mailgun.client');
$mg = new MailgunApi(
$config->get('mailgun.public_api_key'),
$clientAdapter,
$config->get('mailgun.api.endpoint')
);
$mg->setApiVersion($config->get('mailgun.api.version'));
$mg->setSslEnabled($config->get('mailgun.api.ssl', true));
return $mg;
});
$this->app->bind(MailgunContract::class, 'mailgun');
} | php | public function register()
{
/** @var \Illuminate\Config\Repository $config */
$config = $this->app->make('config');
/**
* Register main Mailgun service
*/
$this->app->bind('mailgun', function () use ($config) {
$clientAdapter = $this->app->make('mailgun.client');
$mg = new MailgunApi(
$config->get('mailgun.api_key'),
$clientAdapter,
$config->get('mailgun.api.endpoint')
);
$mg->setApiVersion($config->get('mailgun.api.version'));
$mg->setSslEnabled($config->get('mailgun.api.ssl', true));
return new Service($mg, $this->app->make('view'), $config);
});
/**
* Register the public Mailgun service
*/
$this->app->bind('mailgun.public', function () use ($config) {
$clientAdapter = $this->app->make('mailgun.client');
$mg = new MailgunApi(
$config->get('mailgun.public_api_key'),
$clientAdapter,
$config->get('mailgun.api.endpoint')
);
$mg->setApiVersion($config->get('mailgun.api.version'));
$mg->setSslEnabled($config->get('mailgun.api.ssl', true));
return $mg;
});
$this->app->bind(MailgunContract::class, 'mailgun');
} | [
"public",
"function",
"register",
"(",
")",
"{",
"/** @var \\Illuminate\\Config\\Repository $config */",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"/**\n * Register main Mailgun service\n */",
"$",
"this",
"->... | Register any package services.
@return void | [
"Register",
"any",
"package",
"services",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/MailgunServiceProvider.php#L36-L76 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.send | public function send($view, array $data, Closure $callback, $message = null)
{
$this->message = $message ?: new Message($this->mailgun->MessageBuilder(), $this->config);
$this->callMessageBuilder($callback, $this->message);
$this->renderBody($view, $data);
$message = $this->message->getMessage();
$files = $this->message->getFiles();
$domain = $this->config->get('mailgun.domain');
$response = new Response($this->mailgun->post("{$domain}/messages", $message, $files));
return $response;
} | php | public function send($view, array $data, Closure $callback, $message = null)
{
$this->message = $message ?: new Message($this->mailgun->MessageBuilder(), $this->config);
$this->callMessageBuilder($callback, $this->message);
$this->renderBody($view, $data);
$message = $this->message->getMessage();
$files = $this->message->getFiles();
$domain = $this->config->get('mailgun.domain');
$response = new Response($this->mailgun->post("{$domain}/messages", $message, $files));
return $response;
} | [
"public",
"function",
"send",
"(",
"$",
"view",
",",
"array",
"$",
"data",
",",
"Closure",
"$",
"callback",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
"?",
":",
"new",
"Message",
"(",
"$",
"this",... | @param string|array $view
@param array $data
@param \Closure $callback
@param null $message
@return \Bogardo\Mailgun\Http\Response | [
"@param",
"string|array",
"$view",
"@param",
"array",
"$data",
"@param",
"\\",
"Closure",
"$callback",
"@param",
"null",
"$message"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L57-L71 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.later | public function later($time, $view, array $data, Closure $callback)
{
$message = new Message($this->mailgun->MessageBuilder(), $this->config);
$message->builder()
->setDeliveryTime($this->parseTime($time), $this->config->get('app.timezone', 'UTC'));
return $this->send($view, $data, $callback, $message);
} | php | public function later($time, $view, array $data, Closure $callback)
{
$message = new Message($this->mailgun->MessageBuilder(), $this->config);
$message->builder()
->setDeliveryTime($this->parseTime($time), $this->config->get('app.timezone', 'UTC'));
return $this->send($view, $data, $callback, $message);
} | [
"public",
"function",
"later",
"(",
"$",
"time",
",",
"$",
"view",
",",
"array",
"$",
"data",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"message",
"=",
"new",
"Message",
"(",
"$",
"this",
"->",
"mailgun",
"->",
"MessageBuilder",
"(",
")",
",",
... | @param int|array|\DateTime|Carbon $time
@param string|array $view
@param array $data
@param \Closure $callback
@return \Bogardo\Mailgun\Http\Response | [
"@param",
"int|array|",
"\\",
"DateTime|Carbon",
"$time",
"@param",
"string|array",
"$view",
"@param",
"array",
"$data",
"@param",
"\\",
"Closure",
"$callback"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L81-L88 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.renderBody | protected function renderBody($view, array $data)
{
$data['message'] = $this->message;
if (is_string($view)) {
$this->setHtmlBody($view, $data);
}
if (is_array($view) && isset($view[0])) {
$this->setHtmlBody($view[0], $data);
if (isset($view[1])) {
$this->setTextBody($view[1], $data);
}
} elseif (is_array($view)) {
if (isset($view['html'])) {
$this->setHtmlBody($view['html'], $data);
}
if (isset($view['text'])) {
$this->setTextBody($view['text'], $data);
}
if (isset($view['raw'])) {
$this->setRawBody($view['raw']);
}
}
} | php | protected function renderBody($view, array $data)
{
$data['message'] = $this->message;
if (is_string($view)) {
$this->setHtmlBody($view, $data);
}
if (is_array($view) && isset($view[0])) {
$this->setHtmlBody($view[0], $data);
if (isset($view[1])) {
$this->setTextBody($view[1], $data);
}
} elseif (is_array($view)) {
if (isset($view['html'])) {
$this->setHtmlBody($view['html'], $data);
}
if (isset($view['text'])) {
$this->setTextBody($view['text'], $data);
}
if (isset($view['raw'])) {
$this->setRawBody($view['raw']);
}
}
} | [
"protected",
"function",
"renderBody",
"(",
"$",
"view",
",",
"array",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"'message'",
"]",
"=",
"$",
"this",
"->",
"message",
";",
"if",
"(",
"is_string",
"(",
"$",
"view",
")",
")",
"{",
"$",
"this",
"->",
... | Render HTML and/or text body.
When only a string is passed as the view we default to an HTML body.
When an array without keys is passed as the view; the first value
will be handled as the HTML body. An optional second value will
be handled as the text body.
When an array with keys (html, text or raw) is passed as the view; the
values for those keys will be handled according to the key.
@param string|array $view
@param array $data | [
"Render",
"HTML",
"and",
"/",
"or",
"text",
"body",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L118-L145 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.setHtmlBody | protected function setHtmlBody($view, array $data)
{
$this->message->builder()->setHtmlBody($this->renderView($view, $data));
} | php | protected function setHtmlBody($view, array $data)
{
$this->message->builder()->setHtmlBody($this->renderView($view, $data));
} | [
"protected",
"function",
"setHtmlBody",
"(",
"$",
"view",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"message",
"->",
"builder",
"(",
")",
"->",
"setHtmlBody",
"(",
"$",
"this",
"->",
"renderView",
"(",
"$",
"view",
",",
"$",
"data",
")"... | Set rendered HTML body.
@param string $view
@param array $data | [
"Set",
"rendered",
"HTML",
"body",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L153-L156 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.setTextBody | protected function setTextBody($view, array $data)
{
$this->message->builder()->setTextBody($this->renderView($view, $data));
} | php | protected function setTextBody($view, array $data)
{
$this->message->builder()->setTextBody($this->renderView($view, $data));
} | [
"protected",
"function",
"setTextBody",
"(",
"$",
"view",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"message",
"->",
"builder",
"(",
")",
"->",
"setTextBody",
"(",
"$",
"this",
"->",
"renderView",
"(",
"$",
"view",
",",
"$",
"data",
")"... | Set rendered text body.
@param string $view
@param array $data | [
"Set",
"rendered",
"text",
"body",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L164-L167 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.setRawBody | protected function setRawBody($view)
{
$this->message->builder()->setHtmlBody($view);
$this->message->builder()->setTextBody(strip_tags($view, '<a>'));
} | php | protected function setRawBody($view)
{
$this->message->builder()->setHtmlBody($view);
$this->message->builder()->setTextBody(strip_tags($view, '<a>'));
} | [
"protected",
"function",
"setRawBody",
"(",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"message",
"->",
"builder",
"(",
")",
"->",
"setHtmlBody",
"(",
"$",
"view",
")",
";",
"$",
"this",
"->",
"message",
"->",
"builder",
"(",
")",
"->",
"setTextBody",
... | Set the raw body
@param string $view | [
"Set",
"the",
"raw",
"body"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L174-L178 |
Bogardo/Mailgun | src/Mail/Mailer.php | Mailer.parseTime | private function parseTime($time)
{
$timezone = $this->config->get('app.timezone', 'UTC');
/** @var Carbon $now */
$now = Carbon::now($timezone);
if (is_object($time)) {
$deliveryTime = Carbon::instance($time);
} else {
if (is_array($time)) {
reset($time);
$type = key($time);
$amount = $time[$type];
} else {
$type = 'seconds';
$amount = $time;
}
/** @var Carbon $deliveryTime */
$deliveryTime = Carbon::now($timezone);
switch ($type) {
case 'seconds':
$deliveryTime->addSeconds($amount);
break;
case 'minutes':
$deliveryTime->addMinutes($amount);
break;
case 'hours':
$deliveryTime->addHours($amount);
break;
case 'days':
$deliveryTime->addHours($amount * 24);
break;
default:
$deliveryTime->addSeconds($amount);
break;
}
}
//Calculate boundaries
$max = Carbon::now()->addHours(3 * 24);
if ($deliveryTime->gt($max)) {
$deliveryTime = $max;
} elseif ($deliveryTime->lt($now)) {
$deliveryTime = $now;
}
return $deliveryTime->format(\DateTime::RFC2822);
} | php | private function parseTime($time)
{
$timezone = $this->config->get('app.timezone', 'UTC');
/** @var Carbon $now */
$now = Carbon::now($timezone);
if (is_object($time)) {
$deliveryTime = Carbon::instance($time);
} else {
if (is_array($time)) {
reset($time);
$type = key($time);
$amount = $time[$type];
} else {
$type = 'seconds';
$amount = $time;
}
/** @var Carbon $deliveryTime */
$deliveryTime = Carbon::now($timezone);
switch ($type) {
case 'seconds':
$deliveryTime->addSeconds($amount);
break;
case 'minutes':
$deliveryTime->addMinutes($amount);
break;
case 'hours':
$deliveryTime->addHours($amount);
break;
case 'days':
$deliveryTime->addHours($amount * 24);
break;
default:
$deliveryTime->addSeconds($amount);
break;
}
}
//Calculate boundaries
$max = Carbon::now()->addHours(3 * 24);
if ($deliveryTime->gt($max)) {
$deliveryTime = $max;
} elseif ($deliveryTime->lt($now)) {
$deliveryTime = $now;
}
return $deliveryTime->format(\DateTime::RFC2822);
} | [
"private",
"function",
"parseTime",
"(",
"$",
"time",
")",
"{",
"$",
"timezone",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'app.timezone'",
",",
"'UTC'",
")",
";",
"/** @var Carbon $now */",
"$",
"now",
"=",
"Carbon",
"::",
"now",
"(",
"$",
... | Parse given time and convert it to the required format
@param int|array|Carbon|\DateTime $time
@return string | [
"Parse",
"given",
"time",
"and",
"convert",
"it",
"to",
"the",
"required",
"format"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Mailer.php#L200-L250 |
Bogardo/Mailgun | src/Mail/Message.php | Message.to | public function to($address, $name = "", array $variables = [])
{
if (is_array($address)) {
foreach ($address as $email => $variables) {
$this->variables[$email] = $variables;
$name = isset($variables['name']) ? $variables['name'] : null;
$this->messageBuilder->addToRecipient($email, ['full_name' => $name]);
}
} else {
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addToRecipient($address, ['full_name' => $name]);
}
return $this;
} | php | public function to($address, $name = "", array $variables = [])
{
if (is_array($address)) {
foreach ($address as $email => $variables) {
$this->variables[$email] = $variables;
$name = isset($variables['name']) ? $variables['name'] : null;
$this->messageBuilder->addToRecipient($email, ['full_name' => $name]);
}
} else {
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addToRecipient($address, ['full_name' => $name]);
}
return $this;
} | [
"public",
"function",
"to",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"\"\"",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"address",
")",
")",
"{",
"foreach",
"(",
"$",
"address",
"as",
"$",
"email"... | Add a recipient to the message.
@param string|array $address
@param string $name
@param array $variables
@return \Bogardo\Mailgun\Mail\Message | [
"Add",
"a",
"recipient",
"to",
"the",
"message",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L61-L78 |
Bogardo/Mailgun | src/Mail/Message.php | Message.cc | public function cc($address, $name = "", array $variables = [])
{
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addCcRecipient($address, ['full_name' => $name]);
return $this;
} | php | public function cc($address, $name = "", array $variables = [])
{
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addCcRecipient($address, ['full_name' => $name]);
return $this;
} | [
"public",
"function",
"cc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"\"\"",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"a... | Add a carbon copy to the message.
@param string|array $address
@param string $name
@param array $variables
@return \Bogardo\Mailgun\Mail\Message | [
"Add",
"a",
"carbon",
"copy",
"to",
"the",
"message",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L89-L97 |
Bogardo/Mailgun | src/Mail/Message.php | Message.bcc | public function bcc($address, $name = "", array $variables = [])
{
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addBccRecipient($address, ['full_name' => $name]);
return $this;
} | php | public function bcc($address, $name = "", array $variables = [])
{
if (!empty($variables)) {
$this->variables[$address] = $variables;
}
$this->messageBuilder->addBccRecipient($address, ['full_name' => $name]);
return $this;
} | [
"public",
"function",
"bcc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"\"\"",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"... | Add a blind carbon copy to the message.
@param string|array $address
@param string $name
@param array $variables
@return \Bogardo\Mailgun\Mail\Message | [
"Add",
"a",
"blind",
"carbon",
"copy",
"to",
"the",
"message",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L108-L116 |
Bogardo/Mailgun | src/Mail/Message.php | Message.embed | public function embed($path, $name = null)
{
$name = $name ?: basename($path);
$this->messageBuilder->addInlineImage("@{$path}", $name);
return "cid:{$name}";
} | php | public function embed($path, $name = null)
{
$name = $name ?: basename($path);
$this->messageBuilder->addInlineImage("@{$path}", $name);
return "cid:{$name}";
} | [
"public",
"function",
"embed",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"?",
":",
"basename",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"messageBuilder",
"->",
"addInlineImage",
"(",
"\"@{$path}\"... | Embed a file in the message and get the CID.
@param string $path
@param string $name
@return string | [
"Embed",
"a",
"file",
"in",
"the",
"message",
"and",
"get",
"the",
"CID",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L180-L186 |
Bogardo/Mailgun | src/Mail/Message.php | Message.tag | public function tag($tags)
{
$tags = array_slice((array)$tags, 0, 3);
foreach ($tags as $tag) {
$this->messageBuilder->addTag($tag);
}
return $this;
} | php | public function tag($tags)
{
$tags = array_slice((array)$tags, 0, 3);
foreach ($tags as $tag) {
$this->messageBuilder->addTag($tag);
}
return $this;
} | [
"public",
"function",
"tag",
"(",
"$",
"tags",
")",
"{",
"$",
"tags",
"=",
"array_slice",
"(",
"(",
"array",
")",
"$",
"tags",
",",
"0",
",",
"3",
")",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"this",
"->",
"messageBui... | Add Mailgun tags to the message.
Tag limit is 3.
@param string|array $tags
@return \Bogardo\Mailgun\Mail\Message | [
"Add",
"Mailgun",
"tags",
"to",
"the",
"message",
".",
"Tag",
"limit",
"is",
"3",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L196-L204 |
Bogardo/Mailgun | src/Mail/Message.php | Message.campaign | public function campaign($campaigns)
{
$campaigns = array_slice((array)$campaigns, 0, 3);
foreach ($campaigns as $campaign) {
$this->messageBuilder->addCampaignId($campaign);
}
return $this;
} | php | public function campaign($campaigns)
{
$campaigns = array_slice((array)$campaigns, 0, 3);
foreach ($campaigns as $campaign) {
$this->messageBuilder->addCampaignId($campaign);
}
return $this;
} | [
"public",
"function",
"campaign",
"(",
"$",
"campaigns",
")",
"{",
"$",
"campaigns",
"=",
"array_slice",
"(",
"(",
"array",
")",
"$",
"campaigns",
",",
"0",
",",
"3",
")",
";",
"foreach",
"(",
"$",
"campaigns",
"as",
"$",
"campaign",
")",
"{",
"$",
... | Add Mailgun campaign ID(s) to the message
Campaign ID limit is 3.
@param int|string|array $campaigns
@return \Bogardo\Mailgun\Mail\Message | [
"Add",
"Mailgun",
"campaign",
"ID",
"(",
"s",
")",
"to",
"the",
"message",
"Campaign",
"ID",
"limit",
"is",
"3",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L214-L222 |
Bogardo/Mailgun | src/Mail/Message.php | Message.trackClicks | public function trackClicks($value)
{
$value = $value === 'htmlonly' ? 'html' : $value;
$this->messageBuilder->setClickTracking($value);
return $this;
} | php | public function trackClicks($value)
{
$value = $value === 'htmlonly' ? 'html' : $value;
$this->messageBuilder->setClickTracking($value);
return $this;
} | [
"public",
"function",
"trackClicks",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"===",
"'htmlonly'",
"?",
"'html'",
":",
"$",
"value",
";",
"$",
"this",
"->",
"messageBuilder",
"->",
"setClickTracking",
"(",
"$",
"value",
")",
";",
"... | Toggles clicks tracking on a per-message basis.
This setting has a higher priority than the domain-level setting.
Pass `true`, `false` or 'html' or 'htmlonly'.
@param bool|string $value
@return \Bogardo\Mailgun\Mail\Message | [
"Toggles",
"clicks",
"tracking",
"on",
"a",
"per",
"-",
"message",
"basis",
".",
"This",
"setting",
"has",
"a",
"higher",
"priority",
"than",
"the",
"domain",
"-",
"level",
"setting",
".",
"Pass",
"true",
"false",
"or",
"html",
"or",
"htmlonly",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L247-L253 |
Bogardo/Mailgun | src/Mail/Message.php | Message.setConfigReplyTo | protected function setConfigReplyTo()
{
$address = $this->config->get('mailgun.reply_to.address');
$name = $this->config->get('mailgun.reply_to.name');
if ($address) {
$name = $name ? ['full_name' => $name] : null;
$this->messageBuilder->setReplyToAddress($address, $name);
}
} | php | protected function setConfigReplyTo()
{
$address = $this->config->get('mailgun.reply_to.address');
$name = $this->config->get('mailgun.reply_to.name');
if ($address) {
$name = $name ? ['full_name' => $name] : null;
$this->messageBuilder->setReplyToAddress($address, $name);
}
} | [
"protected",
"function",
"setConfigReplyTo",
"(",
")",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'mailgun.reply_to.address'",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'mailgun.reply_to.name'"... | Apply reply-to address from config. | [
"Apply",
"reply",
"-",
"to",
"address",
"from",
"config",
"."
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L327-L335 |
Bogardo/Mailgun | src/Mail/Message.php | Message.getMessage | public function getMessage()
{
$message = $this->messageBuilder->getMessage();
if (!isset($message['from'])) {
$this->setConfigFrom();
$message = $this->messageBuilder->getMessage();
}
if ($this->variables) {
$message['recipient-variables'] = json_encode($this->variables);
}
if (isset($this->{'o:native-send'})) {
$message['o:native-send'] = $this->{'o:native-send'};
}
return $message;
} | php | public function getMessage()
{
$message = $this->messageBuilder->getMessage();
if (!isset($message['from'])) {
$this->setConfigFrom();
$message = $this->messageBuilder->getMessage();
}
if ($this->variables) {
$message['recipient-variables'] = json_encode($this->variables);
}
if (isset($this->{'o:native-send'})) {
$message['o:native-send'] = $this->{'o:native-send'};
}
return $message;
} | [
"public",
"function",
"getMessage",
"(",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"messageBuilder",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"message",
"[",
"'from'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"set... | Get the message from MessageBuilder and apply custom/extra data
@return array | [
"Get",
"the",
"message",
"from",
"MessageBuilder",
"and",
"apply",
"custom",
"/",
"extra",
"data"
] | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Mail/Message.php#L366-L382 |
Bogardo/Mailgun | src/Validation/Validator.php | Validator.validate | public function validate($address, $mailboxVerification = false)
{
return $this->mailgun->get('address/validate', [
'address' => $address,
'mailbox_verification' => $mailboxVerification
])->http_response_body;
} | php | public function validate($address, $mailboxVerification = false)
{
return $this->mailgun->get('address/validate', [
'address' => $address,
'mailbox_verification' => $mailboxVerification
])->http_response_body;
} | [
"public",
"function",
"validate",
"(",
"$",
"address",
",",
"$",
"mailboxVerification",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"mailgun",
"->",
"get",
"(",
"'address/validate'",
",",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'mailbox_verifi... | Validate an address based on:
- Syntax checks (RFC defined grammar)
- DNS validation
- Spell checks
- Email Service Provider (ESP) specific local-part grammar (if available).
The validation service is intended to validate email addresses submitted through
forms like newsletters, online registrations and shopping carts.
It is not intended to be used for bulk email list scrubbing and Mailgun reserves
the right to disable your account if Mailgun sees it being used as such.
@see https://documentation.mailgun.com/en/latest/api-email-validation.html
@param string $address
@param bool $mailboxVerification
@return \stdClass | [
"Validate",
"an",
"address",
"based",
"on",
":",
"-",
"Syntax",
"checks",
"(",
"RFC",
"defined",
"grammar",
")",
"-",
"DNS",
"validation",
"-",
"Spell",
"checks",
"-",
"Email",
"Service",
"Provider",
"(",
"ESP",
")",
"specific",
"local",
"-",
"part",
"gr... | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Validation/Validator.php#L43-L49 |
Bogardo/Mailgun | src/Validation/Validator.php | Validator.parse | public function parse($addresses, $syntaxOnly = false)
{
if (is_array($addresses)) {
$addresses = implode(',', $addresses);
}
$syntaxOnly = $syntaxOnly ? 'true' : 'false';
return $this->mailgun->get('address/parse', [
'addresses' => $addresses,
'syntax_only' => $syntaxOnly,
])->http_response_body;
} | php | public function parse($addresses, $syntaxOnly = false)
{
if (is_array($addresses)) {
$addresses = implode(',', $addresses);
}
$syntaxOnly = $syntaxOnly ? 'true' : 'false';
return $this->mailgun->get('address/parse', [
'addresses' => $addresses,
'syntax_only' => $syntaxOnly,
])->http_response_body;
} | [
"public",
"function",
"parse",
"(",
"$",
"addresses",
",",
"$",
"syntaxOnly",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"addresses",
")",
")",
"{",
"$",
"addresses",
"=",
"implode",
"(",
"','",
",",
"$",
"addresses",
")",
";",
"}",
"... | Parses an array of email addresses into two lists: parsed addresses and unparsable portions.
The parsed addresses are a list of addresses that are syntactically valid (and optionally
have DNS and ESP specific grammar checks).
The unparsable list is a list of characters sequences that the parser was not able to
understand. These often align with invalid email addresses, but not always.
@param array|string $addresses
@param bool $syntaxOnly
@return mixed | [
"Parses",
"an",
"array",
"of",
"email",
"addresses",
"into",
"two",
"lists",
":",
"parsed",
"addresses",
"and",
"unparsable",
"portions",
".",
"The",
"parsed",
"addresses",
"are",
"a",
"list",
"of",
"addresses",
"that",
"are",
"syntactically",
"valid",
"(",
... | train | https://github.com/Bogardo/Mailgun/blob/faf483ceb7bba104a9739dca330f1fb4e155fdc8/src/Validation/Validator.php#L63-L75 |
madewithlove/elasticsearcher | src/Parsers/FragmentParser.php | FragmentParser.parse | public function parse($body)
{
if (is_array($body)) {
foreach ($body as $key => &$item) {
if ($item instanceof AbstractFragment) {
$parsedBody = $this->parse($item->getBody());
// Add the parsed fragment to the parent.
if ($item->mergeWithParent) {
unset($body[$key]);
$body = array_merge($body, $parsedBody);
} // Replace its current position with the parsed fragment.
else {
$item = $parsedBody;
}
} // Further nesting to be parsed.
elseif (is_array($item)) {
$item = $this->parse($item);
}
}
// Root level fragment, does not have a parent so it can not be merged with one.
} elseif ($body instanceof AbstractFragment) {
$body = $this->parse($body->getBody());
}
return $body;
} | php | public function parse($body)
{
if (is_array($body)) {
foreach ($body as $key => &$item) {
if ($item instanceof AbstractFragment) {
$parsedBody = $this->parse($item->getBody());
// Add the parsed fragment to the parent.
if ($item->mergeWithParent) {
unset($body[$key]);
$body = array_merge($body, $parsedBody);
} // Replace its current position with the parsed fragment.
else {
$item = $parsedBody;
}
} // Further nesting to be parsed.
elseif (is_array($item)) {
$item = $this->parse($item);
}
}
// Root level fragment, does not have a parent so it can not be merged with one.
} elseif ($body instanceof AbstractFragment) {
$body = $this->parse($body->getBody());
}
return $body;
} | [
"public",
"function",
"parse",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"body",
")",
")",
"{",
"foreach",
"(",
"$",
"body",
"as",
"$",
"key",
"=>",
"&",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"AbstractFra... | @param array|AbstractFragment $body
@return array | [
"@param",
"array|AbstractFragment",
"$body"
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Parsers/FragmentParser.php#L19-L45 |
madewithlove/elasticsearcher | src/Abstracts/AbstractQuery.php | AbstractQuery.getData | public function getData($key = null)
{
if ($key !== null) {
return array_key_exists($key, $this->data) ? $this->data[$key] : null;
}
return $this->data;
} | php | public function getData($key = null)
{
if ($key !== null) {
return array_key_exists($key, $this->data) ? $this->data[$key] : null;
}
return $this->data;
} | [
"public",
"function",
"getData",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
")",
"?",
"$",
"this",
"->",
"data",
"[",
"$",... | @return mixed
@param null|string | [
"@return",
"mixed"
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Abstracts/AbstractQuery.php#L93-L100 |
madewithlove/elasticsearcher | src/Abstracts/AbstractQuery.php | AbstractQuery.searchIn | public function searchIn($index, $type = null)
{
// Reset the current state, in case the same instance is re-used.
$this->indices = [];
$this->types = [];
$this->searchInIndices((array) $index);
if ($type !== null) {
$this->searchInTypes((array) $type);
}
} | php | public function searchIn($index, $type = null)
{
// Reset the current state, in case the same instance is re-used.
$this->indices = [];
$this->types = [];
$this->searchInIndices((array) $index);
if ($type !== null) {
$this->searchInTypes((array) $type);
}
} | [
"public",
"function",
"searchIn",
"(",
"$",
"index",
",",
"$",
"type",
"=",
"null",
")",
"{",
"// Reset the current state, in case the same instance is re-used.",
"$",
"this",
"->",
"indices",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"types",
"=",
"[",
"]",
";... | Define on which indices and types the query should be run.
@param string|array $index
@param null|string|array $type | [
"Define",
"on",
"which",
"indices",
"and",
"types",
"the",
"query",
"should",
"be",
"run",
"."
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Abstracts/AbstractQuery.php#L108-L119 |
madewithlove/elasticsearcher | src/Abstracts/AbstractQuery.php | AbstractQuery.buildQuery | protected function buildQuery()
{
$this->setup();
$query = array();
// Index always needs to be provided. _all means a cross index search.
$query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices));
// Type is not required, will search in the entire index.
if (!empty($this->types)) {
$query['type'] = implode(',', array_values($this->types));
}
// Replace Fragments with their raw body.
$query['body'] = $this->fragmentParser->parse($this->body);
// Add all query string params, the SDK will only add known params to the URL.
foreach ($this->queryStringParams as $paramName => $paramValue) {
$query[$paramName] = $paramValue;
}
return $query;
} | php | protected function buildQuery()
{
$this->setup();
$query = array();
// Index always needs to be provided. _all means a cross index search.
$query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices));
// Type is not required, will search in the entire index.
if (!empty($this->types)) {
$query['type'] = implode(',', array_values($this->types));
}
// Replace Fragments with their raw body.
$query['body'] = $this->fragmentParser->parse($this->body);
// Add all query string params, the SDK will only add known params to the URL.
foreach ($this->queryStringParams as $paramName => $paramValue) {
$query[$paramName] = $paramValue;
}
return $query;
} | [
"protected",
"function",
"buildQuery",
"(",
")",
"{",
"$",
"this",
"->",
"setup",
"(",
")",
";",
"$",
"query",
"=",
"array",
"(",
")",
";",
"// Index always needs to be provided. _all means a cross index search.",
"$",
"query",
"[",
"'index'",
"]",
"=",
"empty",... | Build the query by adding all chunks together.
@return array | [
"Build",
"the",
"query",
"by",
"adding",
"all",
"chunks",
"together",
"."
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Abstracts/AbstractQuery.php#L197-L220 |
madewithlove/elasticsearcher | src/Abstracts/AbstractQuery.php | AbstractQuery.run | public function run()
{
$query = $this->buildQuery();
// Execute the query.
$rawResults = $this->searcher->getClient()->search($query);
// Pass response to the class that will do something with it.
$resultParser = $this->getResultParser();
$resultParser->setRawResults($rawResults);
return $resultParser;
} | php | public function run()
{
$query = $this->buildQuery();
// Execute the query.
$rawResults = $this->searcher->getClient()->search($query);
// Pass response to the class that will do something with it.
$resultParser = $this->getResultParser();
$resultParser->setRawResults($rawResults);
return $resultParser;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"buildQuery",
"(",
")",
";",
"// Execute the query.",
"$",
"rawResults",
"=",
"$",
"this",
"->",
"searcher",
"->",
"getClient",
"(",
")",
"->",
"search",
"(",
"$",
"query... | Build and execute the query.
@return AbstractResultParser | [
"Build",
"and",
"execute",
"the",
"query",
"."
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Abstracts/AbstractQuery.php#L274-L286 |
madewithlove/elasticsearcher | src/ElasticSearcher.php | ElasticSearcher.createClient | public function createClient()
{
$client = ClientBuilder::fromConfig($this->environment->all());
$this->setClient($client);
} | php | public function createClient()
{
$client = ClientBuilder::fromConfig($this->environment->all());
$this->setClient($client);
} | [
"public",
"function",
"createClient",
"(",
")",
"{",
"$",
"client",
"=",
"ClientBuilder",
"::",
"fromConfig",
"(",
"$",
"this",
"->",
"environment",
"->",
"all",
"(",
")",
")",
";",
"$",
"this",
"->",
"setClient",
"(",
"$",
"client",
")",
";",
"}"
] | Create a client instance from the ElasticSearch SDK. | [
"Create",
"a",
"client",
"instance",
"from",
"the",
"ElasticSearch",
"SDK",
"."
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/ElasticSearcher.php#L47-L52 |
madewithlove/elasticsearcher | src/Fragments/Traits/SortableTrait.php | SortableTrait.sort | public function sort(array $fields)
{
$sortFields = [];
foreach ($fields as $field => $value) {
// Simplest form, just a field name.
if (is_numeric($field) && !is_array($value)) {
$sortFields[] = $value;
} // Field with direction and/or other options.
else {
$sortFields[] = [$field => $value];
}
}
$this->set('sort', $sortFields);
return $this;
} | php | public function sort(array $fields)
{
$sortFields = [];
foreach ($fields as $field => $value) {
// Simplest form, just a field name.
if (is_numeric($field) && !is_array($value)) {
$sortFields[] = $value;
} // Field with direction and/or other options.
else {
$sortFields[] = [$field => $value];
}
}
$this->set('sort', $sortFields);
return $this;
} | [
"public",
"function",
"sort",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"sortFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"// Simplest form, just a field name.",
"if",
"(",
"is_numeric",
... | @param array $fields
@return $this | [
"@param",
"array",
"$fields"
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Fragments/Traits/SortableTrait.php#L17-L33 |
madewithlove/elasticsearcher | src/Fragments/Traits/SortableTrait.php | SortableTrait.sortBy | public function sortBy($fieldName, $direction = null)
{
$predefinedFields = $this->get('sort');
$sortingFields = [];
// Field exists, prioritize and set direction (if any).
if ($field = $this->findField($fieldName, $predefinedFields)) {
// Field was defined without options.
if (!is_array($field)) {
if ($direction) {
$sortingFields[] = [$fieldName => $direction];
} else {
$sortingFields[] = $fieldName;
}
} else {
// Set direction, otherwise it will just use the default definition.
if ($direction) {
// Defined as {"post_date" : {"order" : "asc", "mode": "avg"}}
if (is_array($field[$fieldName])) {
$field[$fieldName]['order'] = $direction;
} // Defined as {"post_date" : "asc"}
else {
$field[$fieldName] = $direction;
}
}
$sortingFields[] = $field;
}
} // Field does not exist, add it.
else {
$sortingFields[] = [$fieldName => $direction];
}
// Add the predefined fields but remove the one we are sorting on.
if ($predefinedFields) {
foreach ($predefinedFields as $field) {
if (!is_array($field) && $fieldName == $field) {
continue;
} elseif (is_array($field) && array_key_exists($fieldName, $field)) {
continue;
}
$sortingFields[] = $field;
}
}
$this->set('sort', $sortingFields);
return $this;
} | php | public function sortBy($fieldName, $direction = null)
{
$predefinedFields = $this->get('sort');
$sortingFields = [];
// Field exists, prioritize and set direction (if any).
if ($field = $this->findField($fieldName, $predefinedFields)) {
// Field was defined without options.
if (!is_array($field)) {
if ($direction) {
$sortingFields[] = [$fieldName => $direction];
} else {
$sortingFields[] = $fieldName;
}
} else {
// Set direction, otherwise it will just use the default definition.
if ($direction) {
// Defined as {"post_date" : {"order" : "asc", "mode": "avg"}}
if (is_array($field[$fieldName])) {
$field[$fieldName]['order'] = $direction;
} // Defined as {"post_date" : "asc"}
else {
$field[$fieldName] = $direction;
}
}
$sortingFields[] = $field;
}
} // Field does not exist, add it.
else {
$sortingFields[] = [$fieldName => $direction];
}
// Add the predefined fields but remove the one we are sorting on.
if ($predefinedFields) {
foreach ($predefinedFields as $field) {
if (!is_array($field) && $fieldName == $field) {
continue;
} elseif (is_array($field) && array_key_exists($fieldName, $field)) {
continue;
}
$sortingFields[] = $field;
}
}
$this->set('sort', $sortingFields);
return $this;
} | [
"public",
"function",
"sortBy",
"(",
"$",
"fieldName",
",",
"$",
"direction",
"=",
"null",
")",
"{",
"$",
"predefinedFields",
"=",
"$",
"this",
"->",
"get",
"(",
"'sort'",
")",
";",
"$",
"sortingFields",
"=",
"[",
"]",
";",
"// Field exists, prioritize and... | @param string $fieldName
@param string|null $direction
@return $this | [
"@param",
"string",
"$fieldName",
"@param",
"string|null",
"$direction"
] | train | https://github.com/madewithlove/elasticsearcher/blob/1d195d7ac47247c8f8b17d09b85e12e75970fd13/src/Fragments/Traits/SortableTrait.php#L41-L89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.