We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Does the file resolver $source in $vehicle->resolve(’file’, $source, $target) have to be a directory, or can it be an individual file?

    Also, I’m confused by this code in transport.core.php:

    $fileset = array (
        'source' => MODX_BASE_PATH . 'connectors/index.php',
        'target' => "return MODX_CONNECTORS_PATH;",
    );
    $attributes['resolve'][] = array (
        'type' => 'php',
        'source' => dirname(__FILE__) . '/resolvers/resolve.core.php',
        'target' => "return MODX_CONNECTORS_PATH . 'config.core.php';",
    );
    $package->put($fileset, $attributes);


    I thought that the ’target’ was unnecessary (and ignored) in a php resolver.

    And I thought an xPDOFileVehicle was required to move files without a traditional vehicle containing an object. Why is this method used in this case and xPDOFileVehicle used in others?
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: BobRay at Oct 01, 2009, 12:25 AM

      Does the file resolver $source in $vehicle->resolve(’file’, $source, $target) have to be a directory, or can it be an individual file?
      I’m lost here; where is this function you are referring to. It’s not in xPDOVehicle...?

      Quote from: BobRay at Oct 01, 2009, 12:25 AM

      Also, I’m confused by this code in transport.core.php:

      $fileset = array (
          'source' => MODX_BASE_PATH . 'connectors/index.php',
          'target' => "return MODX_CONNECTORS_PATH;",
      );
      $attributes['resolve'][] = array (
          'type' => 'php',
          'source' => dirname(__FILE__) . '/resolvers/resolve.core.php',
          'target' => "return MODX_CONNECTORS_PATH . 'config.core.php';",
      );
      $package->put($fileset, $attributes);


      I thought that the ’target’ was unnecessary (and ignored) in a php resolver.
      It’s not necessary, but the particular resolver script here needs a target in the metadata to know where to put the file.

      Quote from: BobRay at Oct 01, 2009, 12:25 AM

      And I thought an xPDOFileVehicle was required to move files without a traditional vehicle containing an object. Why is this method used in this case and xPDOFileVehicle used in others?
      I honestly don’t remember why I made this decision at the moment, but will post back when I do...
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Oct 01, 2009, 09:53 AM

        I’m lost here; where is this function you are referring to. It’s not in xPDOVehicle...?

        Sorry, I quoted that from memory.

        I meant this:

         $vehicle->resolve($object['resolver_type'],array(
                    'type' => $object['resolver_type'],
                    'source' => $object['resolver_source'],
                    'target' => $object['resolver_target'],
                ));


        Does $object[’resolver_source’] have to be a directory, or can it be an individual file?
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 22303 MODX Staff
          • 10,725 Posts
          I still can’t find the method you are referring to. xPDOVehicle->resolve() takes three parameters, & $transport, & $object, and $options = array(), and is called by the install() process anyway. You should never need to call it.
            • 3749
            • 24,544 Posts
            Quote from: OpenGeek at Oct 01, 2009, 02:53 PM

            I still can’t find the method you are referring to. xPDOVehicle->resolve() takes three parameters, & $transport, & $object, and $options = array(), and is called by the install() process anyway. You should never need to call it.

            modtranportvehicleclass.php:

              /**
                * Adds a post-save resolver to the vehicle.
                *
                * @access public
                * @param string $type The type of resolver (php,file,etc)
                * @param array $options An array of options for the resolver.
                * @return array The added resolver.
                */
                function resolve($type, $options) {
                    $options['type'] = $type;
                    array_push($this->resolvers, $options);
                    return $options;
                }
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 22303 MODX Staff
              • 10,725 Posts
              Hmm, I guess Shaun wrote that; looks the same as if you pass them as attributes in the first example you pasted in this thread: an absolute path to a resolver script for php types and an absolute path to a directory or file for file types.
                • 3749
                • 24,544 Posts
                Quote from: OpenGeek at Oct 01, 2009, 07:42 PM

                Hmm, I guess Shaun wrote that; looks the same as if you pass them as attributes in the first example you pasted in this thread: an absolute path to a resolver script for php types and an absolute path to a directory or file for file types.

                I’ll have to try it.

                I’m still puzzled over transport.core.php, which seems to be doing the same thing in several different ways with file transfers. I don’t know if there’s a reason for the different methods or if they’re just different styles. Considering the simplicity of file transfer, the code seems pretty arcane, especially in its multiple forms. I would have thought this would do it:

                $fv = new xPDOFileVehicle($type, $source, $target);
                $package->put($fv);


                My tendency is always to try to move complexity upstream in non time-critical code. But then, I’m sure there’s plenty of stuff going on in the install that I’m not aware of and it may well require the code to be the way it is.



                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting