Comments (6)
Thank you for putting effort in the improvement of the Yii framework.
We have reviewed your pull request.
Unfortunately a use case is missing. It is required to get a better understanding of the pull request and helps us to determine the necessity and applicability of the suggested change to the framework.
Could you supply us with a use case please? Please be as detailed as possible and show some code!
Thanks!
This is an automated comment, triggered by adding the label pr:missing usecase
.
from arrays.
Here are some use cases:
- When you want to generate/print multi-level structure for comments
- When you want to generate/print multi-level menu
- When you want to generate tree (nested set) for use with js plugins:
https://mbraak.github.io/jqTree/
http://mjsarfatti.com/sandbox/nestedSortable/
from arrays.
- When you want to generate/print multi-level structure for comments
- When you want to generate/print multi-level menu
Why aren't you iterating and outputting it right away?
protected function renderComments($parentID = null, $i = 0)
{
$out = '';
foreach ($this->comments as $comment) {
if ($comment->parent_id === $parentID) {
$out .= $this->render('comment', [
'comment' => $comment, 'class' => $parentID !== null && $i !== 0 ? 'child-comment' : ''
]);
$i++;
$out .= $this->renderComments($comment->id, $i);
}
}
return $out;
}
- When you want to generate tree (nested set) for use with js plugins
OK, that one makes sense...
from arrays.
Is it possible to get same response using ArrayHelper::map somehow ?
No.
from arrays.
@johonunu CakePHP releases their utility classes in a separate package; you could use that.
https://packagist.org/packages/cakephp/utility
from arrays.
@SamMousa I know that, I just wanted to note that it would be good idea to have it in the core. Most of the methods in Hash class are available inside ArrayHelper, but something like "nest" isn't. I can live without it in core, if I am the only one missing it ;)
from arrays.
Related Issues (20)
- Unexpected default value HOT 1
- ArrayableTrait: toArray doesn't resolve array members when no specific fields/expand is provided
- ArrayHelper::getObjectVars() description seems to be out of date HOT 2
- PHP 8 compatibility with \ArrayAccess
- Adjust input and output for `ArrayHelper::parsePath()` HOT 1
- How to create an array of strings in c language?
- Improve performance of getValueByPath() HOT 4
- Fix tests HOT 2
- Get array value by matcher HOT 1
- Extend the functionality of setValue HOT 3
- update irc link
- update src folder link
- Remove scrutinizer
- Psalm 5.23.1
- Increase MSI to 100
- Remove ArrayHelper::isTraversable
- Problem with support float as keys HOT 2
- ArrayHelper::multisort: remove support use \Closure with return multiple keys HOT 2
- call getter for property if getter exists. HOT 5
- Why methods like map expect array in first parameter instead of iterable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrays.