Xpressengine\Category\CategoryHandler::putItem PHP Méthode

putItem() public méthode

Modify item information
public putItem ( CategoryItem $item ) : CategoryItem
$item Xpressengine\Category\Models\CategoryItem item object
Résultat Xpressengine\Category\Models\CategoryItem
    public function putItem(CategoryItem $item)
    {
        if ($item->isDirty($parentIdName = $item->getParentIdName())) {
            // 내용 수정시 부모 키 변경은 허용하지 않음
            // 부모 키가 변경되는 경우는 반드시 moveTo, setOrder 를
            // 통해 처리되야 함
            $item->{$parentIdName} = $item->getOriginal($parentIdName);
        }
        $item->save();
        return $item;
    }

Usage Example

 public function testPutItem()
 {
     $instance = new CategoryHandler();
     $mockItem = m::mock('Xpressengine\\Category\\Models\\CategoryItem');
     $mockItem->shouldReceive('isDirty')->once()->with('parentId')->andReturn(true);
     $mockItem->shouldReceive('getParentIdName')->andReturn('parentId');
     $mockItem->shouldReceive('getOriginal')->with('parentId')->andReturn(1);
     $mockItem->shouldReceive('setAttribute')->with('parentId', 1);
     $mockItem->shouldReceive('save')->andReturnNull();
     $item = $instance->putItem($mockItem);
     $this->assertInstanceOf('Xpressengine\\Category\\Models\\CategoryItem', $item);
 }
All Usage Examples Of Xpressengine\Category\CategoryHandler::putItem