class EntityShareMedias in Entity Share 7
Class EntityShareMedias.
Hierarchy
- class \EntityShareMediasAbstract
- class \EntityShareMedias
Expanded class hierarchy of EntityShareMedias
File
- modules/
entity_share_medias/ includes/ entity_share_medias.inc, line 288 - Class for handling Medias.
View source
class EntityShareMedias extends EntityShareMediasAbstract {
const WATCHDOG_TYPE = 'entity_share_medias';
const HOOK_PREFIX = 'es_medias_';
/**
* Configuration of the medias to manage.
*
* @var array
* Class configuration of the medias to handle.
*/
protected $mediaTypesConfig = array();
/**
* Get the Media Types Configuration.
*
* @return array
* Class configuration of the medias to handle.
*/
public function getMediaTypesConfig() {
// Alter the media types configurations.
drupal_alter(self::HOOK_PREFIX . 'media_types_config', $this->mediaTypesConfig);
return $this->mediaTypesConfig;
}
/**
* Export the medias of the providers.
*/
public function exportMedias() {
foreach ($this
->getMediaTypesConfig() as $type => $config) {
$class = $config['export'];
$provider = new $class($this->fieldData, $this->fieldName, $this->fieldType, $this->entity, $this->fieldInfo);
if (!$provider instanceof EntityShareMediasExportInterface) {
watchdog(self::WATCHDOG_TYPE, 'The media type %type class must implement EntityShareMediasProviderInterface interface !', array(
'%type' => $type,
), WATCHDOG_WARNING);
continue;
}
if ($provider
->isManagedFieldType()) {
$provider
->exportMedias();
}
}
}
/**
* Import the medias of the providers.
*/
public function importMedias() {
foreach ($this
->getMediaTypesConfig() as $type => $config) {
$class = $config['import'];
$provider = new $class($this->fieldData, $this->fieldName, $this->fieldType, $this->entity, $this->fieldInfo);
if (!$provider instanceof EntityShareMediasImportInterface) {
watchdog(self::WATCHDOG_TYPE, 'The media type %type class must implement EntityShareMediasProviderInterface interface !', array(
'%type' => $type,
), WATCHDOG_WARNING);
continue;
}
if ($provider
->isManagedFieldType()) {
$provider
->importMedias();
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityShareMedias:: |
protected | property | Configuration of the medias to manage. | |
EntityShareMedias:: |
public | function | Export the medias of the providers. | |
EntityShareMedias:: |
public | function | Get the Media Types Configuration. | |
EntityShareMedias:: |
constant | |||
EntityShareMedias:: |
public | function | Import the medias of the providers. | |
EntityShareMedias:: |
constant | |||
EntityShareMediasAbstract:: |
protected | property | Entity object. | |
EntityShareMediasAbstract:: |
protected | property | Field data. | |
EntityShareMediasAbstract:: |
protected | property | Metadatas of the field. | |
EntityShareMediasAbstract:: |
protected | property | Name of the field. | |
EntityShareMediasAbstract:: |
protected | property | Type of the field. | |
EntityShareMediasAbstract:: |
public | function | Constructor. Initialize properties. |