本文整理汇总了PHP中Drupal\file\Entity\File::save方法的典型用法代码示例。如果您正苦于以下问题:PHP File::save方法的具体用法?PHP File::save怎么用?PHP File::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\file\Entity\File
的用法示例。
在下文中一共展示了File::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
entity_create('field_storage_config', array('entity_type' => 'entity_test', 'field_name' => 'image_test', 'type' => 'image', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => 'image_test', 'bundle' => 'entity_test'))->save();
file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = entity_create('file', array('uri' => 'public://example.jpg'));
$this->image->save();
$this->imageFactory = $this->container->get('image.factory');
}
示例2: setUp
protected function setUp()
{
parent::setUp();
FieldStorageConfig::create(array('entity_type' => 'entity_test', 'field_name' => 'image_test', 'type' => 'image', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
FieldConfig::create(['entity_type' => 'entity_test', 'field_name' => 'image_test', 'bundle' => 'entity_test'])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create(['uri' => 'public://example.jpg']);
$this->image->save();
$this->imageFactory = $this->container->get('image.factory');
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('file');
$this->installSchema('file', array('file_usage'));
entity_create('field_storage_config', array('field_name' => 'file_test', 'entity_type' => 'entity_test', 'type' => 'file', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => 'file_test', 'bundle' => 'entity_test'))->save();
file_put_contents('public://example.txt', $this->randomMachineName());
$this->file = entity_create('file', array('uri' => 'public://example.txt'));
$this->file->save();
}
示例4: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('file');
$this->installSchema('file', array('file_usage'));
FieldStorageConfig::create(array('field_name' => 'file_test', 'entity_type' => 'entity_test', 'type' => 'file', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
$this->directory = $this->getRandomGenerator()->name(8);
FieldConfig::create(['entity_type' => 'entity_test', 'field_name' => 'file_test', 'bundle' => 'entity_test', 'settings' => array('file_directory' => $this->directory)])->save();
file_put_contents('public://example.txt', $this->randomMachineName());
$this->file = File::create(['uri' => 'public://example.txt']);
$this->file->save();
}