Skip to content

Instantly share code, notes, and snippets.

@ounziw
Last active April 20, 2022 06:05
Show Gist options
  • Save ounziw/ef2c9afeddcc519bea403152be577f28 to your computer and use it in GitHub Desktop.
Save ounziw/ef2c9afeddcc519bea403152be577f28 to your computer and use it in GitHub Desktop.
packages/attest/ concretecmsで、contentimporterを使って属性と属性セットを登録できるかどうか
<?php
namespace Concrete\Package\Attest;
use Concrete\Core\Package\Package;
use Concrete\Core\Backup\ContentImporter;
use Concrete\Core\Cache\Cache;
defined('C5_EXECUTE') or die("Access Denied.");
class Controller extends Package {
protected $pkgHandle = 'attest';
protected $appVersionRequired = '8.5';
protected $pkgVersion = '0.9';
public function getPackageName() {
return t("attest");
}
public function getPackageDescription() {
return t("attest");
}
public function install() {
$pkg = parent::install();
Cache::disableAll();
$ci = new ContentImporter();
$ci->importContentFile($pkg->getPackagePath() . '/import.xml');
}
}
<?xml version="1.0"?>
<concrete5-cif version="1.0">
<attributekeys>
<attributekey handle="attsample1" name="属性1" package="" searchable="1" indexed="1" type="number" category="collection" />
</attributekeys>
<attributesets>
<attributeset name="サンプル属性" package="" handle="att1" category="collection">
<attributekey handle="attsample1" />
</attributeset>
</attributesets>
</concrete5-cif>
@ounziw
Copy link
Author

ounziw commented Apr 20, 2022

インポート直前に、キャッシュ無効化 Cache::disableAll(); を追加した

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment