diff --git a/media_entity.install b/media_entity.install deleted file mode 100644 index bef9d07..0000000 --- a/media_entity.install +++ /dev/null @@ -1,315 +0,0 @@ - 'The base table for media.', - 'fields' => array( - 'mid' => array( - 'description' => 'Media ID.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'uuid' => array( - 'description' => 'Unique Key: Universally unique identifier for this entity.', - 'type' => 'varchar', - 'length' => 128, - 'not null' => FALSE, - ), - 'bundle' => array( - 'description' => 'The bundle of this media.', - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'default' => '', - ), - 'vid' => array( - 'description' => 'The current {media_revision}.vid version identifier.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - 'default' => NULL, - ), - ), - 'indexes' => array( - 'media_bundle' => array(array('bundle', 4)), - ), - 'unique keys' => array( - 'uuid' => array('uuid'), - 'vid' => array('vid'), - ), - 'primary key' => array('mid'), - ); - - // Media revision table. - $schema['media_revision'] = array( - 'description' => 'Stores information about each saved version of a {media}.', - 'fields' => array( - 'mid' => array( - 'description' => 'The {media} this version belongs to.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'vid' => array( - 'description' => 'The primary identifier for this version.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'revision_uid' => array( - 'description' => 'The {users}.uid that created this version.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'log' => array( - 'description' => 'The log entry explaining the changes in this version.', - 'type' => 'text', - 'not null' => FALSE, - 'size' => 'big', - ), - 'revision_timestamp' => array( - 'description' => 'The Unix timestamp when the version was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'langcode' => array( - 'description' => 'The {language}.langcode of this version.', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ), - ), - 'indexes' => array( - 'mid' => array('mid'), - 'revision_uid' => array('revision_uid'), - 'media_langcode' => array('langcode'), - ), - 'foreign keys' => array( - 'versioned_media' => array( - 'table' => 'media', - 'columns' => array('mid' => 'mid'), - ), - 'version_author' => array( - 'table' => 'users', - 'columns' => array('revision_uid' => 'uid'), - ), - ), - 'primary key' => array('vid'), - ); - - // Media base fields storage. - $schema['media_field_data'] = array( - 'description' => 'Base table for media properties.', - 'fields' => array( - 'mid' => array( - 'description' => 'The primary identifier for a media.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'vid' => array( - 'description' => 'The current {media_revision}.vid version identifier.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'bundle' => array( - 'description' => 'The {media_type}.bundle of this media.', - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'default' => '', - ), - 'langcode' => array( - 'description' => 'The {language}.langcode of these media property values.', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ), - 'default_langcode' => array( - 'description' => 'Indicates that this row holds data for original language of this media.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'name' => array( - 'description' => 'The name of this media.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'uid' => array( - 'description' => 'The {users}.uid that owns this media; initially, this is the user that published it.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'status' => array( - 'description' => 'Boolean indicating whether the media translation is published (visible to non-administrators).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'resource_id' => array( - 'description' => 'Base ID of a media resource, that is associated with the media entity. Understood by the appropriate media plugin.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'type' => array( - 'description' => 'Type of the media entity. Provides information about the plugin that should be used with the media entity.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'created' => array( - 'description' => 'The Unix timestamp when the media translation was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'changed' => array( - 'description' => 'The Unix timestamp when the media translation was most recently saved.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'media_changed' => array('changed'), - 'media_created' => array('created'), - 'media_default_langcode' => array('default_langcode'), - 'media_langcode' => array('langcode'), - 'media_type' => array(array('type', 4)), - 'mid' => array('mid'), - ), - 'foreign keys' => array( - 'media_base' => array( - 'table' => 'media', - 'columns' => array('mid' => 'mid'), - ), - 'media_publisher' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - 'primary key' => array('mid', 'langcode'), - ); - - // Revision table for media base fields.. - $schema['media_field_revision'] = array( - 'description' => 'Revision table for media base fields.', - 'fields' => array( - 'mid' => array( - 'description' => 'The primary identifier for a media.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'vid' => array( - 'description' => 'The current {media_revision}.vid version identifier.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'langcode' => array( - 'description' => 'The {language}.langcode of these media property values.', - 'type' => 'varchar', - 'length' => 12, - 'not null' => TRUE, - 'default' => '', - ), - 'default_langcode' => array( - 'description' => 'Indicates that this row holds data for original language of this media.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'name' => array( - 'description' => 'The name of this media.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'uid' => array( - 'description' => 'The {users}.uid that owns this media; initially, this is the user that published it.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'status' => array( - 'description' => 'Boolean indicating whether the media translation is published (visible to non-administrators).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'resource_id' => array( - 'description' => 'Base ID of a media resource, that is associated with the media entity. Understood by the appropriate media plugin.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'type' => array( - 'description' => 'Type of the media entity. Provides information about the plugin that should be used with the media entity.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'created' => array( - 'description' => 'The Unix timestamp when the media translation was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'changed' => array( - 'description' => 'The Unix timestamp when the media translation was most recently saved.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'indexes' => array( - 'uid' => array('uid'), - 'media_default_langcode' => array('default_langcode'), - 'media_langcode' => array('langcode'), - ), - 'foreign keys' => array( - 'versioned_media' => array( - 'table' => 'media', - 'columns' => array('mid' => 'mid'), - ), - 'media_publisher' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - 'primary key' => array('vid', 'langcode'), - ); - - return $schema; -} diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index c45f44c..281da68 100644 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -27,8 +27,9 @@ class MediaController extends ControllerBase { * An array suitable for drupal_render(). */ public function page(MediaInterface $media) { - $build = $this->buildPage($media); - $build['#title'] = String::checkPlain($media->label()); + $build = array( + 'media' => $this->entityManager()->getViewBuilder('media')->view($media), + ); foreach ($media->uriRelationships() as $rel) { // Set the node path as the canonical URL to prevent duplicate content. @@ -67,19 +68,6 @@ class MediaController extends ControllerBase { } /** - * Builds a media page render array. - * - * @param \Drupal\media_entity\MediaInterface $media - * The media we are displaying. - * - * @return array - * An array suitable for drupal_render(). - */ - protected function buildPage(MediaInterface $media) { - return array('media' => $this->entityManager()->getViewBuilder('media')->view($media)); - } - - /** * Page callback: Provides the media submission form. * * @param $media_bundle diff --git a/src/Entity/Media.php b/src/Entity/Media.php index 45afab0..48e0146 100644 --- a/src/Entity/Media.php +++ b/src/Entity/Media.php @@ -265,11 +265,6 @@ class Media extends ContentEntityBase implements MediaInterface { ->setRevisionable(TRUE) ->setSetting('default_value', '') ->setSetting('max_length', 255) - ->setDisplayOptions('view', array( - 'label' => 'hidden', - 'type' => 'string', - 'weight' => -5, - )) ->setDisplayOptions('form', array( 'type' => 'string', 'weight' => -5, diff --git a/src/MediaStorage.php b/src/MediaStorage.php index 667c539..f9ba264 100644 --- a/src/MediaStorage.php +++ b/src/MediaStorage.php @@ -38,10 +38,13 @@ class MediaStorage extends ContentEntityDatabaseStorage implements MediaStorageI // Marking the respective fields as NOT NULL makes the indexes more // performant. + $schema['media_field_data']['fields']['type']['not null'] = TRUE; + $schema['media_field_data']['fields']['resource_id']['not null'] = TRUE; $schema['media_field_data']['fields']['changed']['not null'] = TRUE; $schema['media_field_data']['fields']['created']['not null'] = TRUE; $schema['media_field_data']['fields']['default_langcode']['not null'] = TRUE; $schema['media_field_data']['fields']['status']['not null'] = TRUE; + $schema['media_field_data']['fields']['name']['not null'] = TRUE; $schema['media_field_revision']['fields']['default_langcode']['not null'] = TRUE; // @todo Revisit index definitions in https://drupal.org/node/2015277.