sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function getSourceFile(MediaInterface $media) {
// Get the source field for the media type.
$source_field = $this->getSourceFieldName($media->bundle());
if (empty($source_field)) {
throw new NotFoundHttpException("Source field not set for {$media->bundle()} media");
}
// Get the file ... | Gets the value of a source field for a Media.
@param \Drupal\media\MediaInterface $media
Media whose source field you are searching for.
@return \Drupal\file\FileInterface
File if it exists
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException | entailment |
public function updateSourceField(
MediaInterface $media,
$resource,
$mimetype
) {
$source_field = $this->getSourceFieldName($media->bundle());
$file = $this->getSourceFile($media);
// Update it.
$this->updateFile($file, $resource, $mimetype);
$file->save();
// Set fields provide... | Updates a media's source field with the supplied resource.
@param \Drupal\media\MediaInterface $media
The media to update.
@param resource $resource
New file contents as a resource.
@param string $mimetype
New mimetype of contents.
@throws HttpException | entailment |
protected function updateFile(FileInterface $file, $resource, $mimetype = NULL) {
$uri = $file->getFileUri();
$destination = fopen($uri, 'wb');
if (!$destination) {
throw new HttpException(500, "File $uri could not be opened to write.");
}
$content_length = stream_copy_to_stream($resource, $... | Updates a File's binary contents on disk.
@param \Drupal\file\FileInterface $file
File to update.
@param resource $resource
Stream holding the new contents.
@param string $mimetype
Mimetype of new contents. | entailment |
public function putToNode(
NodeInterface $node,
MediaTypeInterface $media_type,
TermInterface $taxonomy_term,
$resource,
$mimetype,
$content_location
) {
$existing = $this->islandoraUtils->getMediaReferencingNodeAndTerm($node, $taxonomy_term);
if (!empty($existing)) {
// Just up... | Creates a new Media using the provided resource, adding it to a Node.
@param \Drupal\node\NodeInterface $node
The node to reference the newly created Media.
@param \Drupal\media\MediaTypeInterface $media_type
Media type for new media.
@param \Drupal\taxonomy\TermInterface $taxonomy_term
Term from the 'Behavior' vocabu... | entailment |
protected function generateTypeList($entity_type, $bundle_type, $entity_add_form, $bundle_add_form, NodeInterface $node, $field) {
$type_definition = $this->entityTypeManager->getDefinition($bundle_type);
$build = [
'#theme' => 'entity_add_list',
'#bundles' => [],
'#cache' => ['tags' => $type... | Renders a list of content types to add as members. | entailment |
protected function getFaceList()
{
if (!function_exists('face_detect')) {
$msg = 'PHP Facedetect extension must be installed.
See http://www.xarg.org/project/php-facedetect/ for more details';
throw new \Exception($msg);
}
if ($this->maxExecutionT... | getFaceList get faces positions and sizes
@access protected
@return array | entailment |
protected function getFaceListFromClassifier($classifier)
{
$faceList = face_detect($this->imagePath, __DIR__ . $classifier);
if (!$faceList) {
$faceList = array();
}
return $faceList;
} | getFaceListFromClassifier
@param string $classifier
@access protected
@return array | entailment |
protected function getSafeZoneList()
{
if (!isset($this->safeZoneList)) {
$this->safeZoneList = array();
}
// the local key is the current image width-height
$key = $this->originalImage->getImageWidth() . '-' . $this->originalImage->getImageHeight();
if (!isset($... | getSafeZoneList
@access private
@return array | entailment |
public function read($path) {
$meta = $this->readStream($path);
if (!$meta) {
return FALSE;
}
if (isset($meta['stream'])) {
$meta['contents'] = stream_get_contents($meta['stream']);
fclose($meta['stream']);
unset($meta['stream']);
}
return $meta;
} | {@inheritdoc} | entailment |
public function readStream($path) {
$response = $this->fedora->getResource($path);
if ($response->getStatusCode() != 200) {
return FALSE;
}
$meta = $this->getMetadataFromHeaders($response);
$meta['path'] = $path;
if ($meta['type'] == 'file') {
$meta['stream'] = StreamWrapper::getR... | {@inheritdoc} | entailment |
public function getMetadata($path) {
$response = $this->fedora->getResourceHeaders($path);
if ($response->getStatusCode() != 200) {
return FALSE;
}
$meta = $this->getMetadataFromHeaders($response);
$meta['path'] = $path;
return $meta;
} | {@inheritdoc} | entailment |
protected function getMetadataFromHeaders(Response $response) {
$last_modified = \DateTime::createFromFormat(
\DateTime::RFC1123,
$response->getHeader('Last-Modified')[0]
);
// NonRDFSource's are considered files. Everything else is a
// directory.
$type = 'dir';
$links = Psr7\... | Gets metadata from response headers.
@param \GuzzleHttp\Psr7\Response $response
Response. | entailment |
public function listContents($directory = '', $recursive = FALSE) {
// Strip leading and trailing whitespace and /'s.
$normalized = trim($directory, ' \t\n\r\0\x0B/');
// Exit early if it's a file.
$meta = $this->getMetadata($normalized);
if ($meta['type'] == 'file') {
return [];
}
//... | {@inheritdoc} | entailment |
protected function transformToMetadata($uri) {
if (is_array($uri)) {
return $uri;
}
$exploded = explode($this->fedora->getBaseUri(), $uri);
return $this->getMetadata($exploded[1]);
} | Normalizes data for listContents().
@param string $uri
Uri. | entailment |
public function write($path, $contents, Config $config) {
$headers = [
'Content-Type' => $this->mimeTypeGuesser->guess($path),
];
$response = $this->fedora->saveResource(
$path,
$contents,
$headers
);
$code = $response->getStatusCode();
if (!in_array($code, [201, ... | {@inheritdoc} | entailment |
public function writeStream($path, $contents, Config $config) {
return $this->write($path, $contents, $config);
} | {@inheritdoc} | entailment |
public function updateStream($path, $contents, Config $config) {
return $this->write($path, $contents, $config);
} | {@inheritdoc} | entailment |
public function delete($path) {
$response = $this->fedora->deleteResource($path);
$code = $response->getStatusCode();
if ($code == 204) {
// Deleted so check for a tombstone as well.
$tomb_code = $this->deleteTombstone($path);
if (!is_null($tomb_code)) {
return $tomb_code;
}
... | {@inheritdoc} | entailment |
public function createDir($dirname, Config $config) {
$response = $this->fedora->saveResource(
$dirname
);
$code = $response->getStatusCode();
if (!in_array($code, [201, 204])) {
return FALSE;
}
return $this->getMetadata($dirname);
} | {@inheritdoc} | entailment |
private function deleteTombstone($path) {
$response = $this->fedora->getResourceHeaders($path);
$return = NULL;
if ($response->getStatusCode() == 410) {
$return = FALSE;
$link_headers = Psr7\parse_header($response->getHeader('Link'));
if ($link_headers) {
$tombstones = array_filter... | Delete a tombstone for a path if it exists.
@param string $path
The original deleted resource path.
@return bool|null
NULL if no tombstone, TRUE if tombstone deleted, FALSE otherwise. | entailment |
public function put(MediaInterface $media, Request $request) {
$content_type = $request->headers->get('Content-Type', "");
if (empty($content_type)) {
throw new BadRequestHttpException("Missing Content-Type header");
}
// Since we update both the Media and its File, do this in a transaction.
... | Updates a source file for a Media.
@param \Drupal\media\MediaInterface $media
The media whose source file you want to update.
@param \Symfony\Component\HttpFoundation\Request $request
The request object.
@return \Symfony\Component\HttpFoundation\Response
204 on success.
@throws \Symfony\Component\HttpKernel\Exceptio... | entailment |
public function putToNode(
NodeInterface $node,
MediaTypeInterface $media_type,
TermInterface $taxonomy_term,
Request $request
) {
$content_type = $request->headers->get('Content-Type', "");
if (empty($content_type)) {
throw new BadRequestHttpException("Missing Content-Type header");
... | Adds a Media to a Node using the specified field.
@param \Drupal\node\NodeInterface $node
The Node to which you want to add a Media.
@param \Drupal\media\MediaTypeInterface $media_type
Media type for new media.
@param \Drupal\taxonomy\TermInterface $taxonomy_term
Term from the 'Behavior' vocabulary to give to new medi... | entailment |
public function putToNodeAccess(AccountInterface $account, RouteMatch $route_match) {
// We'd have 404'd already if node didn't exist, so no need to check.
// Just hack it out of the route match.
$node = $route_match->getParameter('node');
return AccessResult::allowedIf($node->access('update', $account)... | Checks for permissions to update a node and create media.
@param \Drupal\Core\Session\AccountInterface $account
Account for user making the request.
@param \Drupal\Core\Routing\RouteMatch $route_match
Route match to get Node from url params.
@return \Drupal\Core\Access\AccessResultInterface
Access result. | entailment |
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
// Construct guzzle client to middleware that adds JWT.
$stack = HandlerStack::create();
$stack->push(static::addJwt($container->get('jwt.authentication.jwt')));
$client = new Client([
... | {@inheritdoc} | entailment |
public static function addJwt(JwtAuth $jwt) {
return function (callable $handler) use ($jwt) {
return function (
RequestInterface $request,
array $options
) use (
$handler,
$jwt
) {
$request = $request->withHeader('Authorization', 'Bearer ' . $jwt->generateT... | Guzzle middleware to add a header to outgoing requests.
@param \Drupal\jwt\Authentication\Provider\JwtAuth $jwt
JWT. | entailment |
public function ensure($force = FALSE) {
// Check fedora root for sanity.
$response = $this->fedora->getResourceHeaders('');
if ($response->getStatusCode() != 200) {
return [[
'severity' => RfcLogLevel::ERROR,
'message' => '%url returned %status',
'context' => [
'%ur... | {@inheritdoc} | entailment |
protected function generateData(EntityInterface $entity) {
$data = parent::generateData($entity);
// Find media belonging to node that has the source term, and set its file
// url in the data array.
$source_term = $this->utils->getTermForUri($this->configuration['source_term_uri']);
if (!$source_te... | Override this to return arbitrary data as an array to be json encoded. | entailment |
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$schemes = $this->utils->getFilesystemSchemes();
$scheme_options = array_combine($schemes, $schemes);
$form = parent::buildConfigurationForm($form, $form_state);
$form['event']['#disabled'] = 'disabled';
$form['s... | {@inheritdoc} | entailment |
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$tid = $form_state->getValue('source_term');
$term = $this->entityTypeManager->getStorage('taxonomy_term')->load($tid);
$this->configuration['source_term_uri'] = ... | {@inheritdoc} | entailment |
protected function getEntityById($entity_id) {
$entity_ids = $this->entityTypeManager->getStorage('media_type')
->getQuery()->condition('id', $entity_id)->execute();
$id = reset($entity_ids);
if ($id !== FALSE) {
return $this->entityTypeManager->getStorage('media_type')->load($id);
}
re... | Find a media_type by id and return it or nothing.
@param string $entity_id
The media type.
@return \Drupal\Core\Entity\EntityInterface|string
Return the loaded entity or nothing.
@throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
Thrown by getStorage() if the entity type doesn't exist.
@throws \Drupa... | entailment |
public function register()
{
$this->app->singleton('pushover', function($app)
{
return new Pushover($app['config']);
});
$this->app->booting(function()
{
$loader = AliasLoader::getInstance();
$loader->alias('Pushover', 'Dyaa\Pushover\Faca... | Register the service provider.
@return void | entailment |
static public function definition()
{
return array( 'fields' => array( 'id' => array( 'name' => 'ID',
'datatype' => 'integer',
... | Returns the definition array for eZTagsObject
@return array | entailment |
public function updatePathString()
{
$parentTag = $this->getParent( true );
$pathStringPrefix = $parentTag instanceof self ? $parentTag->attribute( 'path_string' ) : '/';
$this->setAttribute( 'path_string', $pathStringPrefix . $this->attribute( 'id' ) . '/' );
$this->store();
... | Updates path string of the tag and all of it's children and synonyms. | entailment |
public function updateDepth()
{
$parentTag = $this->getParent( true );
$depth = $parentTag instanceof self ? $parentTag->attribute( 'depth' ) + 1 : 1;
$this->setAttribute( 'depth', $depth );
$this->store();
foreach ( $this->getSynonyms( true ) as $s )
{
... | Updates depth of the tag and all of it's children and synonyms. | entailment |
public function getParent( $mainTranslation = false )
{
if ( $mainTranslation )
return self::fetchWithMainTranslation( $this->attribute( 'parent_id' ) );
return self::fetch( $this->attribute( 'parent_id' ) );
} | Returns tag parent
@param bool $mainTranslation
@return eZTagsObject | entailment |
public function getChildren( $offset = 0, $limit = null, $mainTranslation = false )
{
return self::fetchByParentID( $this->attribute( 'id' ), $offset, $limit, $mainTranslation );
} | Returns first level children tags
@param bool $mainTranslation
@param int $offset
@param int $limit
@return eZTagsObject[] | entailment |
public function getRelatedObjects()
{
// Not an easy task to fetch published objects with API and take care of current_version, status
// and attribute version, so just use SQL to fetch all related object ids in one go
$tagID = (int) $this->attribute( 'id' );
$db = eZDB::instance();... | Returns objects related to this tag
@return eZContentObject[] | entailment |
public function getRelatedObjectsCount()
{
// Not an easy task to fetch published objects with API and take care of current_version, status
// and attribute version, so just use SQL to fetch the object count in one go
$tagID = (int) $this->attribute( 'id' );
$db = eZDB::instance();
... | Returns the count of objects related to this tag
@return int | entailment |
public function getSubTreeLimitations()
{
if ( $this->attribute( 'main_tag_id' ) != 0 )
return array();
return parent::fetchObjectList( eZContentClassAttribute::definition(), null,
array( 'data_type_string' => 'eztags',
... | Returns list of eZContentClassAttribute objects (represented as subtree limitations)
@return eZContentClassAttribute[] | entailment |
public function getSubTreeLimitationsCount()
{
if ( $this->attribute( 'main_tag_id' ) != 0 )
return 0;
return parent::count( eZContentClassAttribute::definition(),
array( 'data_type_string' => 'eztags',
... | Returns count of eZContentClassAttribute objects (represented as subtree limitation count)
@return int | entailment |
public function isInsideSubTreeLimit()
{
/** @var eZTagsObject[] $path */
$path = $this->getPath( true, true );
if ( is_array( $path ) && !empty( $path ) )
{
foreach ( $path as $tag )
{
if ( $tag->getSubTreeLimitationsCount() > 0 )
... | Checks if any of the parents have subtree limits defined
@return bool | entailment |
public function getMainTag( $mainTranslation = false )
{
if ( $mainTranslation )
return self::fetchWithMainTranslation( $this->attribute( 'main_tag_id' ) );
return self::fetch( $this->attribute( 'main_tag_id' ) );
} | Returns the main tag for synonym
@param bool $mainTranslation
@return eZTagsObject | entailment |
public function getIcon()
{
$ini = eZINI::instance( 'eztags.ini' );
/** @var array $iconMap */
$iconMap = $ini->variable( 'Icons', 'IconMap' );
$defaultIcon = $ini->variable( 'Icons', 'Default' );
if ( $this->attribute( 'main_tag_id' ) > 0 )
$tag = $this->getMain... | Returns icon associated with the tag, while respecting hierarchy structure
@return string | entailment |
public function getUrl( $clean = false )
{
/** @var eZTagsObject[] $path */
$path = $this->getPath();
$fullPathCount = $this->getPathCount( true );
$urlPrefix = trim( eZINI::instance( 'eztags.ini' )->variable( 'GeneralSettings', 'URLPrefix' ) );
$urlPrefix = trim( $urlPrefix,... | Returns the URL of the tag, to be used in tags/view
@param bool $clean
@return string | entailment |
public function getPath( $reverseSort = false, $mainTranslation = false )
{
$pathArray = explode( '/', trim( $this->attribute( 'path_string' ), '/' ) );
if ( !is_array( $pathArray ) || empty( $pathArray ) || count( $pathArray ) == 1 )
return array();
$pathArray = array_slice( $... | Returns the array of eZTagsObject objects which are parents of this tag
@param bool $reverseSort
@param bool $mainTranslation
@return eZTagsObject[] | entailment |
public function getPathCount( $mainTranslation = false )
{
$pathArray = explode( '/', trim( $this->attribute( 'path_string' ), '/' ) );
if ( !is_array( $pathArray ) || empty( $pathArray ) || count( $pathArray ) == 1 )
return 0;
$pathArray = array_slice( $pathArray, 0, count( $p... | Returns the count of eZTagsObject objects which are parents of this tag
@param bool $mainTranslation
@return int | entailment |
public function getParentString()
{
$keywordsArray = array();
/** @var eZTagsObject[] $path */
$path = $this->getPath( false, true );
if ( is_array( $path ) && !empty( $path ) )
{
foreach ( $path as $tag )
{
$synonymsCount = $tag->getS... | Returns the parent string of the tag
@return string | entailment |
public function updateModified()
{
$pathArray = explode( '/', trim( $this->attribute( 'path_string' ), '/' ) );
if ( $this->attribute( 'main_tag_id' ) > 0 )
array_push( $pathArray, $this->attribute( 'main_tag_id' ) );
if ( !empty( $pathArray ) )
{
$db = eZDB... | Updates modified timestamp on current tag and all of its parents
Expensive to run through API, so SQL takes care of it | entailment |
public function registerSearchObjects($relatedObjects = null)
{
$eZTagsINI = eZINI::instance( 'eztags.ini' );
if ( eZINI::instance( 'site.ini' )->variable( 'SearchSettings', 'DelayedIndexing' ) !== 'disabled'
|| $eZTagsINI->variable( 'SearchSettings', 'ReindexWhenDelayedIndexingDisabled... | Registers all objects related to this tag to search engine for processing
@param array|null $relatedObjects when not null, we assume that these are the objects related to the tag, instead
of fetching them. Useful when deleting tags. | entailment |
static public function fetch( $id, $locale = false )
{
if ( is_string( $locale ) )
$tags = self::fetchList( array( 'id' => $id ), null, null, false, $locale );
else
$tags = self::fetchList( array( 'id' => $id ) );
if ( is_array( $tags ) && !empty( $tags ) )
... | Returns eZTagsObject for given ID
@static
@param int $id
@param mixed $locale
@return eZTagsObject | entailment |
static public function fetchWithMainTranslation( $id )
{
$tags = self::fetchList( array( 'id' => $id ), null, null, true );
if ( is_array( $tags ) && !empty( $tags ) )
return $tags[0];
return false;
} | Returns eZTagsObject for given ID, using the main translation of the tag
@static
@param int $id
@return eZTagsObject | entailment |
static public function fetchList( $params, $limits = null, $sorts = null, $mainTranslation = false, $locale = false )
{
$customConds = self::fetchCustomCondsSQL( $params, $mainTranslation, $locale );
if ( is_array( $params ) )
{
$newParams = array();
foreach ( $param... | Returns array of eZTagsObject objects for given params
@static
@param array $params
@param array $limits
@param array $sorts
@param bool $mainTranslation
@param mixed $locale
@return eZTagsObject[] | entailment |
static public function fetchListCount( $params, $mainTranslation = false, $locale = false )
{
$customConds = self::fetchCustomCondsSQL( $params, $mainTranslation, $locale );
if ( is_array( $params ) )
{
$newParams = array();
foreach ( $params as $key => $value )
... | Returns count of eZTagsObject objects for given params
@static
@param mixed $params
@param bool $mainTranslation
@param mixed $locale
@return int | entailment |
static public function fetchCustomCondsSQL( $params, $mainTranslation = false, $locale = false )
{
$customConds = is_array( $params ) && !empty( $params ) ? " AND " : " WHERE ";
$customConds .= " eztags.id = eztags_keyword.keyword_id ";
if ( $mainTranslation !== false )
{
... | Returns the SQL for custom fetching of tags with eZPersistentObject
@static
@param mixed $params
@param bool $mainTranslation
@param mixed $locale
@return string | entailment |
static public function fetchLimitations()
{
/** @var eZTagsObject[] $tags */
$tags = self::fetchList( array( 'parent_id' => 0, 'main_tag_id' => 0 ), null, null, true );
if ( !is_array( $tags ) )
return array();
$returnArray = array();
foreach ( $tags as $tag )
... | Returns the list of limitations that eZ Tags support
@static
@return array | entailment |
static public function fetchByParentID( $parentID, $offset = 0, $limit = null, $mainTranslation = false )
{
if ( $offset === 0 && $limit === null )
{
$limits = null;
}
else
{
$limits = array( 'offset' => $offset, 'limit' => $limit );
}
... | Returns array of eZTagsObject objects for given parent ID
@static
@param int $parentID
@param bool $mainTranslation
@param int $offset
@param int $limit
@return eZTagsObject[] | entailment |
static public function fetchSynonyms( $mainTagID, $mainTranslation = false )
{
return self::fetchList( array( 'main_tag_id' => $mainTagID ), null, null, $mainTranslation );
} | Returns array of eZTagsObject objects that are synonyms of provided tag ID
@static
@param int $mainTagID
@param bool $mainTranslation
@return eZTagsObject[] | entailment |
static public function fetchByKeyword( $keyword, $mainTranslation = false )
{
return self::fetchList( array( 'keyword' => $keyword ), null, null, $mainTranslation );
} | Returns array of eZTagsObject objects for given keyword
@static
@param mixed $keyword
@param bool $mainTranslation
@return eZTagsObject[] | entailment |
static public function fetchByPathString( $pathString, $mainTranslation = false )
{
return self::fetchList( array( 'path_string' => array( 'like', $pathString . '%' ),
'main_tag_id' => 0 ), null, null, $mainTranslation );
} | Returns the array of eZTagsObject objects for given path string
@static
@param string $pathString
@param bool $mainTranslation
@return eZTagsObject[] | entailment |
static public function fetchByRemoteID( $remoteID, $mainTranslation = false )
{
$tagsList = self::fetchList( array( 'remote_id' => $remoteID ), null, null, $mainTranslation );
if ( is_array( $tagsList ) && !empty( $tagsList ) )
return $tagsList[0];
return null;
} | Fetches tag by remote ID
@static
@param string $remoteID
@param bool $mainTranslation
@return eZTagsObject|null | entailment |
static public function fetchByUrl( $url, $mainTranslation = false )
{
$urlArray = is_array( $url ) ? $url : explode( '/', ltrim( $url, '/' ) );
if ( !is_array( $urlArray ) || empty( $urlArray ) )
return null;
$parentID = 0;
for ( $i = 0; $i < count( $urlArray ) - 1; $i++... | Fetches tag by URL
@static
@param string $url
@param bool $mainTranslation
@return eZTagsObject|null | entailment |
public function recursivelyDeleteTag()
{
foreach ( $this->getChildren( 0, null, true ) as $child )
{
$child->recursivelyDeleteTag();
}
$relatedObjects = $this->getRelatedObjects();
foreach ( $this->getSynonyms( true ) as $synonym )
{
$synonym... | Recursively deletes all tags below this tag, including self | entailment |
public function moveChildrenBelowAnotherTag( eZTagsObject $targetTag )
{
$currentTime = time();
$children = $this->getChildren( 0, null, true );
foreach ( $children as $child )
{
$childSynonyms = $child->getSynonyms( true );
foreach ( $childSynonyms as $childS... | Moves all children of this tag below another tag
@param eZTagsObject $targetTag | entailment |
public function transferObjectsToAnotherTag( $destination )
{
if ( !$destination instanceof self )
{
$destination = self::fetchWithMainTranslation( (int) $destination );
if ( !$destination instanceof self )
return;
}
foreach ( $this->getTagAtt... | Transfers all objects related to this tag, to another tag
@param eZTagsObject|int $destination | entailment |
public function remove( $conditions = null, $extraConditions = null )
{
foreach ( $this->getTagAttributeLinks() as $tagAttributeLink )
{
$tagAttributeLink->remove();
}
foreach ( $this->getTranslations() as $translation )
{
$translation->remove();
... | Removes self, while also removing related translations and links to objects
@param mixed $conditions
@param mixed $extraConditions | entailment |
static public function exists( $tagID, $keyword, $parentID )
{
$db = eZDB::instance();
$sql = "SELECT COUNT(*) AS row_count FROM eztags, eztags_keyword
WHERE eztags.id = eztags_keyword.keyword_id AND
eztags.parent_id = " . (int) $parentID . " AND
eztag... | Returns if tag with provided keyword and parent ID already exists, not counting tag with provided tag ID
@static
@param int $tagID
@param string $keyword
@param int $parentID
@return bool | entailment |
static public function subTreeByTagID( $params = array(), $tagID = 0 )
{
if ( !is_numeric( $tagID ) || (int) $tagID < 0 )
return false;
$tag = self::fetch( (int) $tagID );
if ( (int) $tagID > 0 && !$tag instanceof self )
return false;
if ( $tag instanceof se... | Fetches subtree of tags by specified parameters
@static
@param array $params
@param int $tagID
@return eZTagsObject[] | entailment |
static public function subTreeCountByTagID( $params = array(), $tagID = 0 )
{
if ( !is_numeric( $tagID ) || (int) $tagID < 0 )
return 0;
$tag = self::fetch( (int) $tagID );
if ( (int) $tagID > 0 && !$tag instanceof self )
return 0;
if ( $tag instanceof self ... | Fetches subtree tag count by specified parameters
@static
@param array $params
@param int $tagID
@return int | entailment |
static public function generateModuleResultPath( $tag = false, $urlToGenerate = null, $textPart = false, $mainTranslation = true )
{
$moduleResultPath = array();
if ( is_string( $textPart ) )
{
$moduleResultPath[] = array( 'text' => $textPart,
... | Generates module result path for this tag, used in all module views
@static
@param mixed $tag
@param mixed $urlToGenerate
@param mixed $textPart
@param bool $mainTranslation
@return array | entailment |
public function getMainTranslation()
{
/** @var eZContentLanguage $language */
$language = eZContentLanguage::fetch( $this->attribute( 'main_language_id' ) );
if ( $language instanceof eZContentLanguage )
return $this->translationByLocale( $language->attribute( 'locale' ) );
... | Returns the main translation of this tag
@return eZTagsKeyword | entailment |
public function translationByLanguageID( $languageID )
{
/** @var eZContentLanguage $language */
$language = eZContentLanguage::fetch( $languageID );
if ( $language instanceof eZContentLanguage )
return $this->translationByLocale( $language->attribute( 'locale' ) );
retu... | Returns translation of the tag for provided language ID
@param int $languageID
@return eZTagsKeyword | entailment |
public function getKeyword( $locale = false )
{
if ( $this->attribute( 'id' ) == null )
return $this->Keyword;
$translation = $this->translationByLocale( $locale === false ? $this->CurrentLanguage : $locale );
if ( $translation instanceof eZTagsKeyword )
return $tran... | Returns the tag keyword, locale aware
@param mixed $locale
@return string | entailment |
public function languageNameArray()
{
$languageNameArray = array();
$translations = $this->getTranslations();
foreach ( $translations as $translation )
{
$languageName = $translation->languageName();
if ( is_array( $languageName ) )
$language... | Returns the array of eZTagsKeyword->languageName() arrays, for every translation of the tag
@return array | entailment |
public function updateMainTranslation( $locale )
{
$trans = $this->translationByLocale( $locale );
/** @var eZContentLanguage $language */
$language = eZContentLanguage::fetchByLocale( $locale );
if ( !$trans instanceof eZTagsKeyword || !$language instanceof eZContentLanguage )
... | Sets the main translation of the tag to provided locale
@param string $locale
@return bool | entailment |
public function updateLanguageMask( $mask = false )
{
if ( $mask === false )
{
$locales = array();
foreach ( $this->getTranslations() as $translation )
{
$locales[] = $translation->attribute( 'locale' );
}
$mask = eZContent... | Updates language mask of the tag based on current translations or provided language mask
@param mixed $mask | entailment |
public function setAlwaysAvailable( $alwaysAvailable )
{
$languageMask = (int) $this->attribute( 'language_mask' ) & ~1;
$zerothBit = $alwaysAvailable ? 1 : 0;
$this->setAttribute( 'language_mask', $languageMask | $zerothBit );
$this->store();
$mainTranslation = $this->getM... | Sets/unsets always available flag for this tag
@param bool $alwaysAvailable | entailment |
public function lookup(EntityInterface $entity) {
if ($entity->id() != NULL) {
$drupal_uri = $entity->toUrl()->setAbsolute()->toString();
$drupal_uri .= '?_format=jsonld';
$token = "Bearer " . $this->jwtProvider->generateToken();
$linked_uri = $this->geminiClient->findByUri($drupal_uri, $tok... | Lookup this entity's URI in the Gemini db and return the other URI.
@param \Drupal\Core\Entity\EntityInterface $entity
The entity to look for.
@return string|null
Return the URI or null
@throws \Drupal\Core\Entity\EntityMalformedException
If the entity cannot be converted to a URL. | entailment |
static public function autocomplete( $args )
{
$http = eZHTTPTool::instance();
$searchString = trim( $http->postVariable( 'search_string' ), '' );
$autoCompleteType = eZINI::instance( 'eztags.ini' )->variable( 'GeneralSettings', 'AutoCompleteType' );
if ( empty( $searchString ) )
... | Provides auto complete results when adding tags to object
@static
@param array $args
@return array | entailment |
static public function suggest( $args )
{
$http = eZHTTPTool::instance();
$searchEngine = eZINI::instance()->variable( 'SearchSettings', 'SearchEngine' );
if ( !class_exists( 'eZSolr' ) || $searchEngine != 'ezsolr' )
return array( 'status' => 'success', 'message' => '', 'tags' =... | Provides suggestion results when adding tags to object
@static
@param array $args
@return array | entailment |
static public function children( $args )
{
$ezTagsINI = eZINI::instance( 'eztags.ini' );
$params = array();
// Missing: a limit parameter; generateOutput would need to pass it to eZTagsObject::fetchList
return self::generateOutput(
$params,
$args[0],
... | Provides children in a specific tree
@static
@param array $args
@return array | entailment |
static public function tagtranslations( $args )
{
$returnArray = array(
'status' => 'success',
'message' => '',
'translations' => false
);
$http = eZHTTPTool::instance();
$tagID = (int) $http->postVariable( 'tag_id', 0 );
$tag = eZTagsObj... | Returns requested tag translations
@static
@param array $args
@return array | entailment |
static public function treeConfig( $args )
{
$returnArray = array(
'status' => 'success',
'message' => '',
'config' => array(
'hideRootTag' => false,
'rootTag' => array()
)
);
if ( !isset( $args[1] ) )
{... | Returns config for tree view plugin
@static
@param array $args
@return array | entailment |
static public function tree( $args )
{
$returnArray = array(
'status' => 'success',
'message' => '',
'children' => array()
);
$tagID = 0;
if ( isset( $args[0] ) && is_numeric( $args[0] ) )
{
$tagID = (int)$args[0];
}
... | Returns children tags formatted for tree view plugin
@static
@param array $args
@return array | entailment |
static protected function generateOutput( array $params, $subTreeLimit, $hideRootTag, $locale )
{
$subTreeLimit = (int) $subTreeLimit;
$hideRootTag = (bool) $hideRootTag;
$locale = (string) $locale;
if ( empty( $locale ) )
return array( 'status' => 'success', 'message' ... | Generates output for use with autocomplete and suggest methods
@static
@param array $params
@param int $subTreeLimit
@param bool $hideRootTag
@param string $locale
@return array | entailment |
public function fire()
{
$title = $this->argument('title');
$msg = $this->argument('msg');
$url = $this->option('url');
$urltitle = $this->option('urltitle');
$debug = $this->option('debug');
$sound = $this->option('sound');
$dev... | Execute the console command.
@return mixed | entailment |
protected function getOptions()
{
return [
['url', null, InputOption::VALUE_OPTIONAL, 'URL to send.', null],
['urltitle', null, InputOption::VALUE_OPTIONAL, 'URL Title to send.', null],
['sound', null, InputOption::VALUE_OPTIONAL, 'Set notification Sound.', null],
... | Get the console command options.
@return array | entailment |
public function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters )
{
switch ( $operatorName )
{
case 'eztags_parent_string':
{
$operatorValue = self::generateParentString( $namedParameters['... | Executes the PHP function for the operator cleanup and modifies $operatorValue.
@param eZTemplate $tpl
@param string $operatorName
@param array $operatorParameters
@param string $rootNamespace
@param string $currentNamespace
@param mixed $operatorValue
@param array $namedParameters | entailment |
static public function generateParentString( $tagID )
{
$tag = eZTagsObject::fetchWithMainTranslation( $tagID );
if ( !$tag instanceof eZTagsObject )
return '(' . ezpI18n::tr( 'extension/eztags/tags/edit', 'no parent' ) . ')';
return $tag->getParentString();
} | Generates tag hierarchy string for given tag ID
@static
@param int $tagID
@return string | entailment |
static public function getSimplifiedUserAccess( $module, $function )
{
$user = eZUser::currentUser();
$userAccess = $user->hasAccessTo( $module, $function );
$userAccess['simplifiedLimitations'] = array();
if ( $userAccess['accessWord'] != 'limited' )
return $userAccess;... | Shorthand method to check user access policy limitations for a given module/policy function.
Returns the same array as eZUser::hasAccessTo(), with "simplifiedLimitations".
'simplifiedLimitations' array holds all the limitations names as defined in module.php.
If your limitation name is not defined as a key, then your u... | entailment |
static public function tagsChildren( $args )
{
$http = eZHTTPTool::instance();
$filter = urldecode( trim( $http->getVariable( 'filter', '' ) ) );
if ( !isset( $args[0] ) || !is_numeric( $args[0] ) )
return array( 'count' => 0, 'offset' => false, 'filter' => $filter, 'data' => ar... | Returns the JSON encoded string of children tags for supplied GET params
Used in YUI version of children tags list in admin interface
@static
@param array $args
@return string | entailment |
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$options = [];
foreach (['node', 'media', 'taxonomy_term'] as $content_entity) {
$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($content_entity);
foreach ($bundles as $bundle => $bundle_prope... | {@inheritdoc} | entailment |
public function evaluate() {
foreach ($this->getContexts() as $context) {
if ($context->hasContextValue()) {
$entity = $context->getContextValue();
if (!empty($this->configuration['bundles'][$entity->bundle()])) {
return !$this->isNegated();
}
}
}
return $this->... | {@inheritdoc} | entailment |
public function summary() {
if (empty($this->configuration['bundles'])) {
return $this->t('No bundles are selected.');
}
return $this->t(
'Entity bundle in the list: @bundles',
[
'@bundles' => implode(', ', $this->configuration['field']),
]
);
} | {@inheritdoc} | entailment |
public function createSqlParts( $params )
{
$returnArray = array( 'tables' => '', 'joins' => '', 'columns' => '' );
if ( !isset( $params['parent_tag_id'] ) )
{
return $returnArray;
}
if ( is_array( $params['parent_tag_id'] ) )
{
$parentTagID... | Creates and returns SQL parts used in fetch functions
@param array $params
@return array | entailment |
protected function getSpecialOffset(\Imagick $original, $targetWidth, $targetHeight)
{
return $this->getRandomEdgeOffset($original, $targetWidth, $targetHeight);
} | get special offset for class
@param \Imagick $original
@param int $targetWidth
@param int $targetHeight
@return array | entailment |
protected function getHighestEnergyPoint(\Imagick $image)
{
$size = $image->getImageGeometry();
// It's more performant doing random pixel uplook via GD
$im = imagecreatefromstring($image->getImageBlob());
if ($im === false) {
$msg = 'GD failed to create image from string... | By doing random sampling from the image, find the most energetic point on the passed in
image
@param \Imagick $image
@return array | entailment |
public static function getSubscribedEvents() {
$events[JwtAuthEvents::VALIDATE][] = ['validate'];
$events[JwtAuthEvents::VALID][] = ['loadUser'];
$events[JwtAuthEvents::GENERATE][] = ['setIslandoraClaims'];
return $events;
} | {@inheritdoc} | entailment |
public function setIslandoraClaims(JwtAuthGenerateEvent $event) {
global $base_secure_url;
// Standard claims, validated at JWT validation time.
$event->addClaim('iat', time());
$expiry_setting = \Drupal::config(IslandoraSettingsForm::CONFIG_NAME)
->get(IslandoraSettingsForm::JWT_EXPIRY);
$ex... | Sets claims for a Islandora consumer on the JWT.
@param \Drupal\jwt\Authentication\Event\JwtAuthGenerateEvent $event
The event. | entailment |
public function validate(JwtAuthValidateEvent $event) {
$token = $event->getToken();
$uid = $token->getClaim('webid');
$name = $token->getClaim('sub');
$roles = $token->getClaim('roles');
$url = $token->getClaim('iss');
if ($uid === NULL || $name === NULL || $roles === NULL || $url === NULL) {
... | Validates that the Islandora data is present in the JWT.
@param \Drupal\jwt\Authentication\Event\JwtAuthValidateEvent $event
A JwtAuth event. | entailment |
public function loadUser(JwtAuthValidEvent $event) {
$token = $event->getToken();
$uid = $token->getClaim('webid');
$user = $this->userStorage->load($uid);
$event->setUser($user);
} | Load and set a Drupal user to be authentication based on the JWT's uid.
@param \Drupal\jwt\Authentication\Event\JwtAuthValidEvent $event
A JwtAuth event. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.