本文整理汇总了PHP中site_object_factory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP site_object_factory::create方法的具体用法?PHP site_object_factory::create怎么用?PHP site_object_factory::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类site_object_factory
的用法示例。
在下文中一共展示了site_object_factory::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _valid_perform
function _valid_perform(&$request, &$response)
{
if (!($objects_amounts = $this->dataspace->get('amount'))) {
$request->set_status(REQUEST_STATUS_FAILURE);
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
return;
}
$objects_data =& fetch_by_node_ids(array_keys($objects_amounts), $this->_define_catalog_object(), $counter);
if (!$objects_data) {
$request->set_status(REQUEST_STATUS_FAILURE);
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
return;
}
$object =& site_object_factory::create($this->_define_catalog_object());
if (!method_exists($object, 'get_cart_item')) {
$request->set_status(REQUEST_STATUS_FAILURE);
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
return;
}
$cart =& cart::instance();
foreach ($objects_data as $key => $object_data) {
$object->import_attributes($object_data);
$cart_item =& $object->get_cart_item();
$cart_item->set_amount($objects_amounts[$key]);
$cart->add_item($cart_item);
}
$response->redirect('/root/cart?popup=1');
}
示例2: _valid_perform
function _valid_perform()
{
$tree =& tree::instance();
$params = array();
$params['identifier'] = $this->dataspace->get('identifier');
$params['parent_path'] = $this->dataspace->get('parent_path');
$params['class'] = $this->dataspace->get('class_name');
$params['title'] = $this->dataspace->get('title');
$object =& site_object_factory::create($params['class']);
$is_root = false;
if (!($parent_data = fetch_one_by_path($params['parent_path']))) {
if ($params['parent_path'] == '/') {
$is_root = true;
} else {
error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
}
}
if (!$is_root) {
$params['parent_node_id'] = $parent_data['node_id'];
} else {
$params['parent_node_id'] = 0;
}
$object->import_attributes($params);
if (!$object->create($is_root)) {
error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
}
if (!$is_root) {
$parent_object =& site_object_factory::instance($parent_data['class_name']);
$parent_object->import_attributes($parent_data);
$access_policy =& access_policy::instance();
$access_policy->save_object_access($object, $parent_object);
}
return new close_popup_response(RESPONSE_STATUS_FORM_SUBMITTED);
}
示例3: create
function test_save()
{
$metadata['id'] = 1;
$metadata['keywords'] = 'keywords';
$metadata['description'] = 'description';
$o =& site_object_factory :: create('site_object');
$o->import_attributes($metadata);
$result_id = $o->save_metadata();
$this->assertNotNull($result_id);
$sys_metadata_db_table =& db_table_factory :: instance('sys_metadata');
$metadata_row = $sys_metadata_db_table->get_row_by_id($result_id);
$this->assertTrue(is_array($metadata_row));
$this->assertTrue(isset($metadata_row['object_id']));
$this->assertTrue(isset($metadata_row['keywords']));
$this->assertTrue(isset($metadata_row['description']));
$this->assertEqual($metadata_row['object_id'], 1);
$this->assertEqual($metadata_row['keywords'], 'keywords');
$this->assertEqual($metadata_row['description'], 'description');
}
示例4: perform
function perform(&$request, &$response)
{
$request->set_status(REQUEST_STATUS_FAILURE);
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
if (!($id = $request->get_attribute('id'))) {
return;
}
if (!($object_data =& fetch_one_by_node_id((int) $id))) {
return;
}
$object =& site_object_factory::create($object_data['class_name']);
if (!method_exists($object, 'get_cart_item')) {
$request->set_status(REQUEST_STATUS_FAILURE);
return;
}
$object->import_attributes($object_data);
$cart_item =& $object->get_cart_item();
$cart =& cart::instance();
if ($quantity = (int) $request->get_attribute('quantity')) {
$cart_item->set_amount($quantity);
}
$cart->add_item($cart_item);
$request->set_status(REQUEST_STATUS_SUCCESS);
$response->redirect('/root/cart?popup=1');
}
示例5: _valid_perform
function _valid_perform(&$request, &$response)
{
$login = $this->dataspace->get('login');
$password = $this->dataspace->get('password');
$locale_id = $this->dataspace->get('locale_id');
$autologin = $this->dataspace->get('autologin');
$user_object =& site_object_factory::create($this->user_object_class_name);
if ($user_object->login($login, $password, $locale_id)) {
if ($autologin) {
$user =& user::instance();
$user->configure_autologin();
}
$request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
if ($redirect = $this->dataspace->get('redirect')) {
$this->_login_redirect($redirect, $response);
return;
} elseif (isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), '/root/login') === false) {
$response->redirect($_SERVER['HTTP_REFERER']);
return;
} else {
$response->redirect('/');
return;
}
}
$request->set_status(REQUEST_STATUS_FAILURE);
}
示例6: _valid_perform
function _valid_perform(&$request, &$response)
{
$tree =& tree::instance();
$params = array();
$params['identifier'] = $this->dataspace->get('identifier');
$params['class'] = $this->dataspace->get('class_name');
$params['title'] = $this->dataspace->get('title');
$params['parent_node_id'] = $this->dataspace->get('parent_node_id');
$params['controller_id'] = site_object_controller::get_id($this->dataspace->get('controller_name'));
$object =& site_object_factory::create($params['class']);
if (!($parent_data = fetch_one_by_node_id($params['parent_node_id']))) {
error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
}
$object->merge_attributes($params);
if (!$object->create()) {
error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
}
$parent_object =& site_object_factory::create($parent_data['class_name']);
$parent_object->merge_attributes($parent_data);
$access_policy =& access_policy::instance();
$access_policy->save_initial_object_access($object, $parent_object);
$request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
}
示例7: elseif
function &_getSiteObjectTestCase($site_object_class, $tester_postfix = '')
{
if ($tester_postfix) {
$tester_postfix = '_' . $tester_postfix;
}
if (file_exists(PROJECT_DIR . '/tests/cases/site_objects_testers/' . $site_object_class . $tester_postfix . '_tester.class.php')) {
include_once PROJECT_DIR . '/tests/cases/site_objects_testers/' . $site_object_class . $tester_postfix . '_tester.class.php';
$tester_name = $site_object_class . $tester_postfix . '_tester';
$test_case =& new $tester_name($site_object_class);
} elseif (file_exists(LIMB_DIR . '/tests/cases/site_objects_testers/' . $site_object_class . $tester_postfix . '_tester.class.php')) {
include_once LIMB_DIR . '/tests/cases/site_objects_testers/' . $site_object_class . $tester_postfix . '_tester.class.php';
$tester_name = $site_object_class . $tester_postfix . '_tester';
$test_case =& new $tester_name($site_object_class);
} else {
$site_object = site_object_factory::create($site_object_class);
if (is_subclass_of($site_object, 'content_object')) {
$tester_name = 'content_object' . $tester_postfix . '_tester';
include_once LIMB_DIR . '/tests/cases/site_objects_testers/' . $tester_name . '.class.php';
$test_case =& new $tester_name($site_object_class);
} else {
$tester_name = 'site_object' . $tester_postfix . '_tester';
include_once LIMB_DIR . '/tests/cases/site_objects_testers/' . $tester_name . '.class.php';
$test_case =& new $tester_name($site_object_class);
}
}
return $test_case;
}
示例8: perform
function perform(&$request, &$response)
{
$user_object =& site_object_factory :: create($this->_site_object_name);
$user_object->logout();
$response->redirect('/');
}
示例9: array
function &get_site_objects()
{
$site_objects = array();
foreach ($this->get_classes_list() as $class) {
$site_objects[] =& site_object_factory::create($class);
}
return $site_objects;
}
示例10: _valid_perform
function _valid_perform(&$request, &$response)
{
$object_data =& fetch_requested_object($request);
$data = $this->dataspace->export();
$object =& site_object_factory::create('user_object');
$object->save_membership($object_data['id'], $data['membership']);
$request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
}
示例11: _valid_perform
function _valid_perform()
{
$object_data =& fetch_mapped_by_url();
$data = $this->_export();
$object =& site_object_factory::create('user_object');
$object->save_membership($object_data['id'], $data['membership']);
return true;
}
示例12: _valid_perform
function _valid_perform()
{
$object_data =& fetch_mapped_by_url();
$data = $this->dataspace->export();
$object =& site_object_factory::create('user_object');
$object->save_membership($object_data['id'], $data['membership']);
return new response(RESPONSE_STATUS_FORM_SUBMITTED);
}
示例13: _write_create_access_policy
function _write_create_access_policy()
{
$parent_data =& $this->_load_parent_object_data();
$parent_object =& site_object_factory::create($parent_data['class_name']);
$parent_object->merge_attributes($parent_data);
$access_policy =& access_policy::instance();
$access_policy->save_initial_object_access($this->object, $parent_object);
}
示例14: perform
function perform()
{
$object =& site_object_factory::create('user_object');
if (!$object->activate_password()) {
message_box::write_notice('Password activation failed!');
reload('/');
}
return true;
}
示例15: perform
function perform(&$request, &$response)
{
$object =& site_object_factory::create('user_object');
if (!$object->activate_password()) {
message_box::write_notice('Password activation failed!');
$request->set_status(REQUEST_STATUS_FAILED);
$response->redirect('/');
}
}