本文整理汇总了PHP中tools::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::serialize方法的具体用法?PHP tools::serialize怎么用?PHP tools::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::serialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: packageModuleAction
/**
* Package a module
* @param string $module
* @return string
*/
protected function packageModuleAction($module = 'core')
{
\tools::rmdir('var/pack/');
\tools::copy_dir('modules/' . $module . '/', 'var/pack/' . $module . '/');
/* If this module has a profile, retrieve profile */
if (is_dir('profiles/' . PROFILE . '/modules/' . $module . '/')) {
/* Remove concats */
$concats = glob('profiles/' . PROFILE . '/modules/' . $module . '/*concat_*');
if (is_array($concats) && !empty($concats)) {
foreach ($concats as $file) {
unlink($file);
}
}
\tools::copy_dir('profiles/' . PROFILE . '/modules/' . $module . '/', 'var/pack/' . $module . '/');
}
/* Clean rights: keep only default rights */
/* Module Rights */
$objModule = \app::getModule($module);
$rolesToRemove = array();
foreach (\app::getModule('core')->getEntity('role')->where('id_role > 4') as $role) {
$rolesToRemove[] = $role->id_role;
$objModule->setRights($role->id_role, 1);
}
\tools::serialize('var/pack/' . $module . '/module', $objModule);
/* Pages rights */
foreach ($objModule->getPages() as $page) {
foreach ($rolesToRemove as $idRole) {
$page->setRights($idRole, 1);
}
\tools::serialize('var/pack/' . $module . '/pages/' . $page->getId(), $page);
}
/* Model rights */
foreach ($objModule->getModel() as $entity) {
foreach ($rolesToRemove as $idRole) {
$entity->setRights($idRole, 15);
foreach ($entity->getFields() as $field) {
$field->setRights($idRole, 7);
}
}
\tools::serialize('var/pack/' . $module . '/model/' . $entity->getName(), $entity);
}
/* generate and send Zip to client */
$phar = new \PharData('profiles/' . PROFILE . '/modules/' . $module . '.zip');
$phar->buildFromDirectory('./var/pack');
\app::$response->setHeader('Content-type', 'application/zip');
return 'profiles/' . PROFILE . '/modules/' . $module . '.zip';
}
示例2: save
/**
* Save the module
* @return bool
*/
public function save()
{
return \tools::serialize(PROFILE_PATH . $this->moduleName . '/pages/' . $this->getId(), $this);
}
示例3: save
/**
* Save the module
* @return bool
*/
public function save()
{
return \tools::serialize(PROFILE_PATH . $this->name . '/module', $this);
}
示例4: save
/**
* Put content in file.obj
* @return string
*/
public function save()
{
return \tools::serialize('modules/' . $this->_module . '/model/' . $this->_entityName, $this);
}