本文整理汇总了PHP中Asset::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset::create方法的具体用法?PHP Asset::create怎么用?PHP Asset::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importTerm
protected function importTerm($node, $parentKey, $uriBase)
{
$attrs = $node->attributes();
$id = strval($attrs->termID);
if (!strlen($id)) {
echo "Warning: Skipping Term with no termID\n";
return;
}
$uri = $uriBase . ':' . $id;
echo "Asset URL is " . $uri . "\n";
$name = strval($node->Name);
echo "Name is " . $name . "\n";
$defn = strval($node->Definition);
echo "Definition is " . $defn . "\n";
if (!($asset = Asset::getByURL($this->db, $uri))) {
$asset = Asset::create($this->db, $this->classname);
echo "Created new term with key " . $asset->key . "\n";
$asset->title = $name;
$asset->description = $defn;
$asset->url[] = $uri;
if ($parentKey) {
$asset->parent = $parentKey;
}
$asset->commit();
} else {
echo "Matched existing term with key " . $asset->key . "\n";
}
foreach ($node->Term as $term) {
$this->importTerm($term, $asset->key, $uriBase);
}
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Asset::create([]);
}
}
示例3: create
public static function create($db, $class = '')
{
if ($class == '') {
$class = 'video';
}
return parent::create($db, $class);
}
示例4: run
/**
* Auto generated seed file
*
* @return void
*/
public function run()
{
\DB::table('assets')->delete();
$brands = array('Dell', 'Asus', 'Acer', 'Samsung', 'Sony', 'HP');
$rooms = DB::table('ceas_rooms')->lists('name');
$dids = DB::table('department')->lists('id');
$types = array('PC', 'Laptop', 'Monitor', 'TV', 'Server', 'Other');
$faker = Faker\Factory::create();
foreach (range(1, 25) as $id) {
Asset::create(['brand_name' => $faker->randomElement($brands), 'room' => $faker->randomElement($rooms), 'active' => $faker->optional($weight = 0.4, $default = '1')->randomElement(array('0', '1')), 'mac_address' => $faker->macAddress, 'ip_address' => $faker->ipv4, 'assignee_name' => $faker->name, 'asset_type' => $faker->randomElement($types), 'department_id' => $faker->randomElement($dids), 'serial_number' => $faker->randomNumber(9), 'asset_tag' => $faker->md5, 'description' => $faker->realText(50)]);
}
}
示例5: import
public function import()
{
$this->asset = Asset::create($this->db, $this->classname);
if (is_array($this->data)) {
foreach ($this->data as $k => $v) {
if (substr($k, 0, 1) == '_') {
continue;
}
$this->asset->{$k} = $v;
}
}
$this->asset->commit();
return $this->asset;
}
示例6: getOrCreateAssetFolderByPath
protected function getOrCreateAssetFolderByPath($path)
{
$folder = Asset_Folder::getByPath($path);
if (!$folder instanceof Asset_Folder) {
str_replace("\\", "/", $path);
$parts = explode("/", $path);
if (empty($parts[count($parts) - 1])) {
$parts = array_slice($parts, 0, -1);
}
$parts = array_slice($parts, 1);
$parentPath = "/";
foreach ($parts as $part) {
$parent = Asset_Folder::getByPath($parentPath);
if ($parent instanceof Asset_Folder) {
$part = Pimcore_File::getValidFilename($part);
$folder = Asset_Folder::getByPath($parentPath . $part);
if (!$folder instanceof Asset_Folder) {
$folder = Asset::create($parent->getId(), array("filename" => $part, "type" => "folder", "userOwner" => $this->getUser()->getId(), "userModification" => $this->getUser()->getId()));
}
$parentPath .= $part . "/";
} else {
Logger::error("parent not found!");
return null;
}
}
}
return $folder;
}
示例7: createLink
/**
* Creates a simple "TYPE 1" link between assets
*
* @param object &$parent_asset The parent asset
* @param object &$child_asset The child asset
*
* @return int
* @access public
*/
function createLink(Asset &$parent_asset, Asset &$child_asset)
{
// Link the asset to the parent asset
$link = array('asset' => &$parent_asset, 'link_type' => 1, 'value' => '', 'sort_order' => NULL, 'is_dependant' => FALSE, 'is_exclusive' => FALSE);
$link_id = $child_asset->create($link);
return $link_id;
}
示例8: testDuplicateAssetPath
/**
* makes sure, that the creation of assets with duplicate paths is not possible
* @expectedException Exception
* @depends testAssetFolderCreate
*/
public function testDuplicateAssetPath()
{
$key = uniqid();
Asset::create(1, array("filename" => $key, "type" => "folder", "userOwner" => 1, "userModification" => 1));
Asset::create(1, array("filename" => $key, "type" => "folder", "userOwner" => 1, "userModification" => 1));
}
示例9: createDirectory
/**
* creates a new folder in current directory
*
* @param string $name
* @return string
*/
function createDirectory($name)
{
$asset = Asset::create($this->asset->getId(), array("filename" => Pimcore_File::getValidFilename($name), "type" => "folder"));
}