本文整理汇总了PHP中Objects类的典型用法代码示例。如果您正苦于以下问题:PHP Objects类的具体用法?PHP Objects怎么用?PHP Objects使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Objects类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvokeResult
/**
* Tests the recovery of internal objects value.
*/
public function testInvokeResult()
{
$objects = new Objects();
$objects[0] = new resources\foo();
$objects[1] = new resources\foo();
$this->assertSame(array('foo from foo', 'foo from foo'), $objects->invoke('getFoo'));
}
示例2: indexAction
public function indexAction()
{
$objectsTable = new Objects();
#$objectsTable->createRowAsFirstChild(3,array('title'=>'nowy'));
#$objectsTable->createRowAfterNode(5,array('title'=>'nowy test'));
#$objectsTable->find(19)->current()->delete();
$this->view->tree = $objectsTable->fetchFullTree();
}
示例3: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// $cats = Category::model()->findAll(array('condition'=>'lft=1 and rgt=2 and level=1','order'=>'title'));
$this->pageTitle = 'Быстрые отзывы покупателей о товарах и услугах';
$cats = Category::getRubsByParentId();
$lasts = Objects::model()->active()->findAll(array('order' => 'created_date DESC', 'limit' => 15));
$last_array = array();
if (!empty($lasts)) {
foreach ($lasts as $last) {
$last_array[] = $last->id;
}
}
/* $criteria = new CDbCriteria;
$criteria->order = 'created_date DESC';
$criteria->limit = 3;
$criteria->addNotInCondition('org_id', $last_array);
$lasts_poll = PollChoice::model()->findAll($criteria);
if(!empty($lasts_poll)){
foreach ($lasts_poll as $last_poll) {
if(!in_array($last_poll->org->id, $last_array)){
$last_array[] = $last_poll->org->id;
$lasts[] = $last_poll->org;
}
}
} */
$this->render('index', array('cats' => $cats, 'lasts' => $lasts));
}
示例4: rebuild
public function rebuild($start_date = null, $end_date = null)
{
if (!$start_date) {
$start_date = config_option('last_sharing_table_rebuild');
}
if ($start_date instanceof DateTimeValue) {
$start_date = $start_date->toMySQL();
}
if ($end_date instanceof DateTimeValue) {
$end_date = $end_date->toMySQL();
}
if ($end_date) {
$end_cond = "AND updated_on <= '{$end_date}'";
}
try {
$object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
$obj_count = 0;
DB::beginWork();
foreach ($object_ids as $id) {
$obj = Objects::findObject($id);
if ($obj instanceof ContentDataObject) {
$obj->addToSharingTable();
$obj_count++;
}
}
set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
DB::commit();
} catch (Exception $e) {
DB::rollback();
Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
}
return $obj_count;
}
示例5: purge_trash
function purge_trash()
{
Env::useHelper("permissions");
$days = config_option("days_on_trash", 0);
$count = 0;
if ($days > 0) {
$date = DateTimeValueLib::now()->add("d", -$days);
$objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
foreach ($objects as $object) {
$concrete_object = Objects::findObject($object->getId());
if (!$concrete_object instanceof ContentDataObject) {
continue;
}
if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
continue;
}
try {
DB::beginWork();
if ($concrete_object instanceof MailContent) {
$concrete_object->delete(false);
} else {
$concrete_object->delete();
}
ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
DB::commit();
$count++;
} catch (Exception $e) {
DB::rollback();
Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
}
}
}
return $count;
}
示例6: getObject
/**
* Return object
*
* @param void
* @return ApplicationDataObject
*/
function getObject()
{
if (is_null($this->object)) {
$this->object = Objects::findObject($this->getObjectId());
}
return $this->object;
}
示例7: getOtherObject
/**
* Return object connected with this action, that is not equal to the one received
*
* @access public
* @param ProjectDataObject $object
* @return ProjectDataObject
*/
function getOtherObject($object) {
if (($object->getObjectId()!= $this->getObjectId()) ) {
return Objects::findObject($this->getObjectId());
} else {
return Objects::findObject($this->getRelObjectId());
}
} // getObject
示例8: mail_do_mark_as_read_unread_objects
function mail_do_mark_as_read_unread_objects($ids_to_mark, $read)
{
$all_accounts = array();
$all_accounts_ids = array();
foreach ($ids_to_mark as $id) {
$obj = Objects::findObject($id);
if ($obj instanceof MailContent && logged_user() instanceof Contact) {
//conversation set the rest of the conversation
$uds_to_mark_from_conver = array();
if (user_config_option('show_emails_as_conversations')) {
$emails_in_conversation = MailContents::getMailsFromConversation($obj);
foreach ($emails_in_conversation as $email) {
//$id is marked on object controller only mark the rest of the conversation
if ($id != $email->getId()) {
$email->setIsRead(logged_user()->getId(), $read);
$uds_to_mark_from_conver[] = $email->getUid();
}
}
}
//make the array with accounts and uids to send to the mail server
//accounts
if (!in_array($obj->getAccountId(), $all_accounts_ids)) {
$account = $obj->getAccount();
//if logged user is owner of this account and is imap
if ($account instanceof MailAccount && $account->getContactId() == logged_user()->getId() && $account->getIsImap()) {
$all_accounts_ids[] = $obj->getAccountId();
$all_accounts[$account->getId()]['account'] = $account;
}
}
//uids
if (in_array($obj->getAccountId(), $all_accounts_ids)) {
//add conversations uids
//mientras ande mal el uid de los mails enviados si estan sincronizados no usar esta parte
/*if (user_config_option('show_emails_as_conversations')) {
foreach ($uds_to_mark_from_conver as $uid_conver){
$all_accounts[$obj->getAccountId()]['uids'][] = $uid_conver;
}
}*/
$all_accounts[$obj->getAccountId()]['folders'][$obj->getImapFolderName()][] = $obj->getUid();
}
}
}
//foreach account send uids by folder to mark in the mail server
foreach ($all_accounts as $account_data) {
$account = $account_data['account'];
$folders = $account_data['folders'];
foreach ($folders as $key => $folder) {
$folder_name = $key;
$uids = $folder;
if (!empty($folder_name)) {
try {
MailUtilities::setReadUnreadImapMails($account, $folder_name, $uids, $read);
} catch (Exception $e) {
Logger::log("Could not set mail as read on mail server, exception:\n" . $e->getMessage());
}
}
}
}
}
示例9: collectProperties
public static function collectProperties($objects, $properties, $defaults = null)
{
$output = array();
foreach ($objects as $object) {
foreach ($properties as $property) {
$output[] = Objects::get($object, $property, $defaults[$property]);
}
}
return $output;
}
示例10: Exception
public static function &get($var, $name, $default = null)
{
if (is_array($var)) {
return Arrays::get($var, $name, $default);
}
if (is_object($var)) {
return Objects::get($var, $name, $default);
}
throw new Exception("\$var must be either an array or object");
}
示例11: getObjectsByTemplate
/**
* Returns all Objects of a Template
*
* @param integer $template_id
* @return array
*/
static function getObjectsByTemplate($template_id) {
$all = self::findAll(array('conditions' => array('`template_id` = ?', $template_id) ));
if (!is_array($all)) return array();
$objs = array();
foreach ($all as $obj) {
$objs[] = Objects::findObject($obj->getObjectId());
}
return $objs;
}
示例12: property_chain
/**
* Connect object properties by chaining it like a.b.c...
* @param $sPropertyChain
* @param $oObject
* @return bool
*/
public static function property_chain($sPropertyChain, $oObject)
{
$sPropertyChain = explode('.', $sPropertyChain);
foreach ($sPropertyChain as $sElement) {
$oObject = Objects::property($sElement, $oObject);
if (!$oObject) {
return false;
}
}
return $oObject;
}
示例13: isSelected
/**
* @todo this will incorrectly evaluate isSelected() as true if the model object is null
* and the choice render returns a 0
* @param type $choice
* @param type $index
* @return type
*/
public function isSelected($choice, $index)
{
if ($this->isEmptyInput()) {
return false;
} else {
$raw = $this->getRawInput();
if (!empty($raw)) {
return $this->getRawInput() == $this->getChoiceRenderer()->getValue($choice, $index);
} else {
return Objects::equals($this->getModelObject(), $choice);
}
}
}
示例14: stringifyArrayElements
private static function stringifyArrayElements($array)
{
$elements = array();
$isAssociative = array_keys($array) !== range(0, sizeof($array) - 1);
array_walk($array, function ($element, $key) use(&$elements, $isAssociative) {
if ($isAssociative) {
$elements[] = "<{$key}> => " . Objects::toString($element);
} else {
$elements[] = Objects::toString($element);
}
});
return $elements;
}
示例15: healPermissionGroup
function healPermissionGroup(SharingTableFlag $flag)
{
if ($flag->getObjectId() > 0) {
try {
$obj = Objects::findObject($flag->getObjectId());
if (!$obj instanceof ContentDataObject) {
$flag->delete();
// if object does not exists then delete the flag
return;
}
DB::beginWork();
// update sharing table
$obj->addToSharingTable();
DB::commit();
} catch (Exception $e) {
DB::rollback();
Logger::log("Failed to heal object permissions for object " . $flag->getObjectId() . " (flag_id = " . $flag->getId() . ")");
return false;
}
// delete flag
$flag->delete();
return true;
} else {
// heal
$controller = new SharingTableController();
$permissions_string = $flag->getPermissionString();
$permission_group_id = $flag->getPermissionGroupId();
$permissions = json_decode($permissions_string);
if ($flag->getMemberId() > 0) {
foreach ($permissions as $p) {
if (!isset($p->m)) {
$p->m = $flag->getMemberId();
}
}
}
try {
DB::beginWork();
// update sharing table
$controller->afterPermissionChanged($permission_group_id, $permissions);
DB::commit();
} catch (Exception $e) {
DB::rollback();
Logger::log("Failed to heal permission group {$permission_group_id} (flag_id = " . $flag->getId() . ")\n" . $e->getTraceAsString());
return false;
}
// delete flag
$flag->delete();
return true;
}
}