Review main Merged

27257[TASK] Add FileCollectionRegistry

Frans Saris CR +2 V +2 Hard +344 −14 updated 02/17/14, 20:04

Commit message

The classes belonging to the FileCollection types are hardwired
in ResourceFactory::createCollectionObject(), therefore you can
not use your own types.

This change introduces a Registry API that makes it possible to
register your own FileCollection type + class and has a generic
way to add the new type to TCA[sys_file_collection].

How to use:
- Register type in ext_localconf.php
  $register->registerFileCollectionClass(full_class_name, your_type);
- Add type to TCA in Configuration/TCA/sys_file_collection.php
  $register->addTypeToTCA(your_type, label, needed_fields);
  return $GLOBALS['TCA']['sys_file_collection'];

Review

  • Code review CR +2
    • Wouter Wolters +2
    • Markus Klein +1
  • Verified V +2
    • Wouter Wolters +2
    • Markus Klein +1

Issues 1

Files 4

Review log 32

Show 7 earlier messages
  1. Frans Saris uploaded patch set 2 02/02/14, 10:16

  2. Frans Saris commented on patch set 2 02/02/14, 10:17

    See forge for instruction on how to register your own type
  3. Stefan Froemken commented on patch set 2 V +1 CR -1 02/02/14, 11:15

    Patch works good, but there are some wording problems in Code and I miss a testcase.

    FileCollectionRegistry.php:38

    It constructs this object or it registers the file collection classes, but it does not creates this object

    FileCollectionRegistry.php:48

    Add an empty row between description and @param

    FileCollectionRegistry.php:65

    It's a collection, not a driver

    FileCollectionRegistry.php:81

    I miss a little description here

    FileCollectionRegistry.php:91

    I'm not sure. Doesn't we have spaces between "."

    FileCollectionRegistryTest.php:149

    There is no test for addTypeToTCA
  4. Frans Saris uploaded patch set 3 02/02/14, 13:46

  5. Frans Saris commented on patch set 2 02/02/14, 13:46

    FileCollectionRegistry.php:38 Reply

    Done

    FileCollectionRegistry.php:48 Reply

    Done

    FileCollectionRegistry.php:65 Reply

    Done

    FileCollectionRegistry.php:81 Reply

    Done

    FileCollectionRegistry.php:91 Reply

    Done
  6. Frans Saris uploaded patch set 4 02/02/14, 14:02

  7. Frans Saris commented on patch set 2 02/02/14, 14:03

    FileCollectionRegistryTest.php:149 Reply

    Done
  1. Mr. Jenkins commented on patch set 1 02/02/14, 16:11

  2. Mr. Jenkins commented on patch set 2 02/02/14, 16:26

  3. Mr. Jenkins commented on patch set 3 02/02/14, 21:56

  4. Mr. Jenkins commented on patch set 4 02/02/14, 22:23

  5. Stefan Froemken voted on patch set 4 V +1 CR +1 02/03/14, 08:59

  6. Wouter Wolters commented on patch set 4 02/03/14, 16:55

    FileCollectionRegistry.php:15

    one tab too much

    FileCollectionRegistry.php:49

    missing types here for some parameters

    FileCollectionRegistry.php:73

    space after elseif

    FileCollectionRegistry.php:126

    spaces around .$type.
  7. Frans Saris uploaded patch set 5 02/12/14, 19:11

  8. Frans Saris commented on patch set 4 02/12/14, 19:12

    FileCollectionRegistry.php:15 Reply

    Done

    FileCollectionRegistry.php:49 Reply

    Done

    FileCollectionRegistry.php:73 Reply

    Done

    FileCollectionRegistry.php:126 Reply

    Done
  9. Mr. Jenkins commented on patch set 5 02/12/14, 19:33

  10. Markus Klein updated the commit message in patch set 5 02/16/14, 14:09

  11. Mr. Jenkins commented on patch set 6 02/16/14, 14:22

  12. Markus Klein commented on patch set 6 CR -1 02/16/14, 14:47

    I made an extensive review.
    This desperately needs proper documentation. So please add a ticket and reference it here.

    FileCollectionRegistry.php:35

    phpdoc missing

    FileCollectionRegistry.php:51

    override what? Description please

    FileCollectionRegistry.php:52

    registering -> registration

    FileCollectionRegistry.php:58

    30 bytes.

    FileCollectionRegistry.php:65

    escaping for \ missing: \\

    FileCollectionRegistry.php:111

    why not simply use empty()? is this faster?

    FileCollectionRegistry.php:112

    Only use that function if you really need the UNSET feature of it. otherwise use the PHP function

    FileCollectionRegistry.php:137

    rename it to fileCollectionTypeExists

    FileCollectionRegistryTest.php:28

    remove indentation

    FileCollectionRegistryTest.php:32

    no need for the full namespace, we're in the same already.

    FileCollectionRegistryTest.php:37

    call it $subject. Fixture is something else. See also commit message from Oli Klee in phpunit and phpunit docs. This was a mistake introduced in the beginning of unit tests in Core and should be changed step by step.

    FileCollectionRegistryTest.php:61

    we're usually using the @expectedException annotation for the test

    FileCollectionRegistryTest.php:68

    IsTooLong

    FileCollectionRegistryTest.php:89

    convention is that the test name starts with method name under test. registerFileCollectionClassOverridesExistingRegisteredFileCollectionClass

    FileCollectionRegistryTest.php:137

    function names start lowercased

    FileCollectionRegistryTest.php:145

    closing ) can be on same line.

    FileCollectionRegistryTest.php:156

    use variables for the static strings to avoid code duplication below.

    FileCollectionRegistryTest.php:171

    Only used once. Put it into test directly. Makes it easier to read the test.
  13. Frans Saris commented on patch set 6 02/17/14, 08:25

    Reply

    Done

    FileCollectionRegistry.php:35 Reply

    Done

    FileCollectionRegistry.php:51 Reply

    Done

    FileCollectionRegistry.php:52 Reply

    Done

    FileCollectionRegistry.php:58 Reply

    Done

    FileCollectionRegistry.php:65 Reply

    Done

    FileCollectionRegistry.php:111 Reply

    This is faster/cleaner

    FileCollectionRegistry.php:112 Reply

    The intention of this functionality is that you can override some thing so I think it is okay to use it here. Also the result is cached in the TCA cache so this is only executed when TCA cache is cleared.

    FileCollectionRegistry.php:137 Reply

    Done

    FileCollectionRegistryTest.php:28 Reply

    Done

    FileCollectionRegistryTest.php:61 Reply

    But then I can not check for the exception code can I?

    FileCollectionRegistryTest.php:68 Reply

    Done

    FileCollectionRegistryTest.php:89 Reply

    Did that to prevent to long names. done

    FileCollectionRegistryTest.php:137 Reply

    Done

    FileCollectionRegistryTest.php:145 Reply

    Done

    FileCollectionRegistryTest.php:156 Reply

    Done

    FileCollectionRegistryTest.php:171 Reply

    Done
  14. Frans Saris uploaded patch set 7 02/17/14, 08:25

  15. Mr. Jenkins commented on patch set 7 02/17/14, 08:38

  16. Markus Klein commented on patch set 7 02/17/14, 09:43

    FileCollectionRegistryTest.php:62

    http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions @expectedExceptionMessage and @expectedExceptionCode exist as well I'd really suggest to use these as we should stay consistent within the Core.

    FileCollectionRegistryTest.php:138

    FileCollectionTypeExists -> fileCollectionTypeExists
  17. Frans Saris uploaded patch set 8 02/17/14, 09:53

  18. Frans Saris commented on patch set 7 02/17/14, 09:53

    FileCollectionRegistryTest.php:62 Reply

    Done

    FileCollectionRegistryTest.php:138 Reply

    Done
  19. Mr. Jenkins commented on patch set 8 02/17/14, 10:35

  20. Markus Klein voted on patch set 8 CR +1 02/17/14, 10:51

  21. Markus Klein voted on patch set 8 V +1 02/17/14, 12:37

  22. Wouter Wolters commented on patch set 8 CR +1 02/17/14, 19:49

    FileCollectionRegistry.php:63

    bytes -> characters?

    FileCollectionRegistry.php:67

    double quotes around the className?
  23. Frans Saris commented on patch set 8 02/17/14, 19:58

    FileCollectionRegistry.php:63 Reply

    php.net: strlen() returns the number of bytes rather than the number of characters in a string

    FileCollectionRegistry.php:67 Reply

    Is not used on other places so do not think we should use it here. Code is inspired from DriverRegistry
  24. Wouter Wolters voted on patch set 8 V +2 CR +2 02/17/14, 20:04

  25. Wouter Wolters merged patch set 9 02/17/14, 20:04