本文整理匯總了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();
}