首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Owncloud +钩子

Owncloud +钩子
EN

Stack Overflow用户
提问于 2015-11-04 20:49:26
回答 1查看 845关注 0票数 2

我试图在我的OwnCloud应用程序Metadata中添加一些钩子,但我似乎搞不清楚(钩子没有被解雇)。

我试着跟踪内容manual/app/init.htmlmanual/app/hooks.html (尽管第二个似乎已经过时了)。

基本上,我现在要做的就是抓住pre-rename钩子,并将一些东西写入文件中。

我的代码是:

myapp/appinfo/app.php

代码语言:javascript
复制
namespace OCA\Metadata\AppInfo;

use OCP\AppFramework\App;

$app = new App('metadata');
$container = $app->getContainer();

$container->query('OCP\INavigationManager')->add(function () use ($container) {
    $urlGenerator = $container->query('OCP\IURLGenerator');
    $l10n = $container->query('OCP\IL10N');
    return [
        // the string under which your app will be referenced in owncloud
        'id' => 'metadata',

        // sorting weight for the navigation. The higher the number, the higher
        // will it be listed in the navigation
        'order' => 10,

        // the route that will be shown on startup
        'href' => $urlGenerator->linkToRoute('metadata.page.index'),

        // the icon that will be shown in the navigation
        // this file needs to exist in img/
        'icon' => $urlGenerator->imagePath('metadata', 'app.svg'),

        // the title of your application. This will be used in the
        // navigation or on the settings page of your app
        'name' => $l10n->t('Metadata'),
    ];
});

\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OC\Metadata\Hooks', 'postRename');

然后是myapp/hooks.php

代码语言:javascript
复制
<?php
namespace OCA\Metadata;

use OC\Files\Filesystem;
use OC\Files\View;

class Hooks {

    // private $userManager;

    public static function postRename($params) {
       file_put_contents("/var/www/data/owncloud_print2.log", "post_rename");
    }
}

任何东西都不会被写到文件里。我也尝试过其他方法,但都没有运气。有人知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-05 11:20:15

我的连接是错的。它应该是:

代码语言:javascript
复制
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Metadata\Hooks', 'postRename');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33531730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档