Exemplo n.º 1
0
    $user = new User();
    $user->setUsername($username);
    // save user
    $user->save();
    writeln($user);
}
foreach (array('Web', 'Life', 'Open Source', 'PHP') as $value) {
    $category = new Category();
    $category->setName($value);
    $user = UserQuery::create()->findPk(rand(1, 3));
    $category->setUser($user);
    // save category
    $category->save();
    // create action
    $actionManager->createAction($category->getUser(), Category::CREATE_CATEGORY, $category);
    writeln($category);
}
for ($i = 0; $i <= 20; $i++) {
    $post = new Post();
    $post->setTitle('Post title ' . $i);
    $post->setBody('Post body ' . $i);
    $user = UserQuery::create()->findPk(rand(1, 3));
    $post->setUser($user);
    $category = $user = CategoryQuery::create()->findPk(rand(1, 9));
    $post->setCategory($category);
    // create post
    $post->save();
    // create action
    $actionManager->createAction($post->getUser(), Post::CREATE_POST, $post, $post->getCategory());
    writeln($post);
}
 /**
  * @param	Post $post The post object to add.
  */
 protected function doAddPost($post)
 {
     $this->collPosts[] = $post;
     $post->setCategory($this);
 }