phproberto / joomla-entity
Joomla! 的实体类
v2.0.0
2019-12-09 09:13 UTC
Requires
- php: ^7.0
Requires (Dev)
- joomla/coding-standards: ~2.0@alpha
- phpunit/phpunit: ^4.8.35
- squizlabs/php_codesniffer: ^2.8
- dev-2.0-dev
- dev-master / 2.0.x-dev
- v2.0.0
- v1.9.0
- v1.8.0
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/build/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/build/engine.io-and-browser-sync-6.2.1
- dev-dependabot/npm_and_yarn/build/socket.io-parser-and-browser-sync-4.2.1
- dev-dependabot/npm_and_yarn/build/ini-1.3.7
This package is auto-updated.
Last update: 2024-09-29 04:42:48 UTC
README
因为开发 Joomla 扩展应该既有趣又简单。
快速入门
让我们用一个快速的例子来说明。这是在 Joomla 中通过 ID 加载文章的实际方法
其中 $article
是一个 stdClass
对象。您可以访问其属性,但它实际上是一个虚构的东西,一个端点。
使用文章实体,您可以这样做
在这里,$article
是一个文章实体。一个向开发者公开其逻辑和资源的对象。
您可以使用该文章实体完成一些很酷的事情
// Use article as entity echo $article->get('title'); // Use params transparently if ($article->param('show_title', '1') === '1') { echo $article->get('title'); } // Check if article is featured if ($article->isFeatured()) { // Do something } // Check if article has an intro image if ($article->hasIntroImage()) { $image = $article->getIntroImage(); echo '<img src="' . JUri::root(true) . '/' . $image['url'] . '" />'; } // Check article state if ($article->isPublished()) { echo 'Article published!'; } // Retrieve article category echo $article->category()->get('title'); // You can modify article properties $article->set('title', 'My modified title'); // And save it try { $article->save(); } catch (\RuntimeException $e) { echo 'There was an error saving article: ' . $e->getMessage(); }
查看完整文档以获取其他示例。
安装
前往 发布部分,并遵循最新版本中的 如何安装/升级
指示。
文档
文档发布在 https://phproberto.github.io/joomla-entity/。
要求
- PHP 7.1+
- Joomla! CMS v3.9+
版权 & 许可证
此库采用 GNU LESSER GENERAL PUBLIC LICENSE 许可。
版权(C)2017-2019 Roberto Segura López - 版权所有。