3

我使用 phpdocumentor 为我的项目生成文档。它为我的功能生成了很好的文档,例如:

    /**
       * Hash generator
       *
       * Long description
       *
       * @param string $password Password
       * @return string
       */
    function generate_hash($password) {
        global $PASSWORD_SALT;
        return crypt($password, $PASSWORD_SALT);
    }

但我还没有找到一种记录 slim 映射的方法(php 框架):

    /**
     * Delete news
     *
     * Delete news by id
     *
     * @link /news/delete/:id
     *
     */
    $app->get('/news/delete/:id', function ($id) use ($app) {
        $item = ORM::for_table('news')->find_one($id);
        if ($item)
            $item->delete();
        $app->redirect('/');
    })->conditions(array('id'=>'\d+'));

记录这样的事情的正确方法是什么?

4

1 回答 1

0

To describe my comment as an answer I'd point you towards something similiar to:

/**
 * Delete news
 *
 * Delete news by id
 *
 * @link /news/delete/:id
 *
 */
public function deleteNewsByID (&$app, $id)
{
     return $app->get('/news/delete/:id', function ($id) use ($app) {
         $item = ORM::for_table('news')->find_one($id);
         if ($item)
             $item->delete();
         $app->redirect('/');
     })->conditions(array('id'=>'\d+'));
}

But I am not familiar with slim so I cannot insure this will work at all. And it is not recommended nor pretty, as stated in the comments below.

于 2013-01-07T14:54:23.420 回答